@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.
- package/package.json +18 -20
- package/src/og/Clock.js +11 -11
- package/src/og/Deferred.js +1 -1
- package/src/og/Events.js +9 -7
- package/src/og/Extent.js +117 -72
- package/src/og/Globe.js +35 -22
- package/src/og/ImageCanvas.js +24 -18
- package/src/og/Lock.js +2 -2
- package/src/og/LonLat.js +40 -37
- package/src/og/Popup.js +21 -15
- package/src/og/QueueArray.js +7 -3
- package/src/og/Rectangle.js +11 -6
- package/src/og/Stack.js +8 -5
- package/src/og/ajax.js +21 -33
- package/src/og/astro/astro.js +5 -5
- package/src/og/astro/earth.js +23 -17
- package/src/og/astro/jd.js +44 -39
- package/src/og/astro/orbit.js +20 -18
- package/src/og/astro/rotation.js +17 -8
- package/src/og/bv/Box.js +7 -3
- package/src/og/bv/Sphere.js +17 -9
- package/src/og/camera/Camera.js +137 -86
- package/src/og/camera/Frustum.js +30 -19
- package/src/og/camera/PlanetCamera.js +30 -26
- package/src/og/control/CompassButton.js +8 -2
- package/src/og/control/Control.js +13 -11
- package/src/og/control/DebugInfo.js +4 -1
- package/src/og/control/EarthCoordinates.js +62 -41
- package/src/og/control/EarthNavigation.js +20 -22
- package/src/og/control/GeoImageDragControl.js +1 -1
- package/src/og/control/KeyboardNavigation.js +12 -12
- package/src/og/control/LayerSwitcher.js +24 -23
- package/src/og/control/Lighting.js +1 -1
- package/src/og/control/MouseNavigation.js +1 -1
- package/src/og/control/ScaleControl.js +1 -1
- package/src/og/control/SegmentBoundVisualization.js +8 -9
- package/src/og/control/ShowFps.js +15 -10
- package/src/og/control/SimpleNavigation.js +8 -10
- package/src/og/control/Sun.js +25 -15
- package/src/og/control/ToggleWireframe.js +5 -5
- package/src/og/control/TouchNavigation.js +58 -45
- package/src/og/control/ZoomControl.js +41 -25
- package/src/og/control/index.js +4 -0
- package/src/og/ellipsoid/Ellipsoid.js +181 -85
- package/src/og/ellipsoid/wgs84.js +4 -4
- package/src/og/entity/BaseBillboard.js +97 -44
- package/src/og/entity/Billboard.js +15 -11
- package/src/og/entity/BillboardHandler.js +314 -64
- package/src/og/entity/Entity.js +106 -74
- package/src/og/entity/EntityCollection.js +72 -49
- package/src/og/entity/GeoObject.js +228 -0
- package/src/og/entity/GeoObjectHandler.js +910 -0
- package/src/og/entity/Geometry.js +29 -26
- package/src/og/entity/GeometryHandler.js +598 -126
- package/src/og/entity/Label.js +74 -40
- package/src/og/entity/LabelHandler.js +47 -246
- package/src/og/entity/LabelWorker.js +213 -0
- package/src/og/entity/Object3d.js +504 -0
- package/src/og/entity/PointCloud.js +81 -33
- package/src/og/entity/PointCloudHandler.js +9 -9
- package/src/og/entity/Polyline.js +39 -39
- package/src/og/entity/Ray.js +61 -28
- package/src/og/entity/ShapeHandler.js +1 -1
- package/src/og/entity/Strip.js +77 -48
- package/src/og/entity/StripHandler.js +27 -27
- package/src/og/entity/index.js +8 -16
- package/src/og/input/KeyboardHandler.js +107 -104
- package/src/og/input/MouseHandler.js +81 -78
- package/src/og/input/TouchHandler.js +55 -51
- package/src/og/layer/BaseGeoImage.js +61 -30
- package/src/og/layer/CanvasTiles.js +26 -24
- package/src/og/layer/GeoImage.js +10 -10
- package/src/og/layer/GeoTexture2d.js +1 -1
- package/src/og/layer/GeoVideo.js +3 -3
- package/src/og/layer/KML.js +66 -40
- package/src/og/layer/Layer.js +27 -17
- package/src/og/layer/Material.js +93 -61
- package/src/og/layer/Vector.js +118 -72
- package/src/og/layer/WMS.js +36 -19
- package/src/og/layer/XYZ.js +55 -48
- package/src/og/light/LightSource.js +47 -40
- package/src/og/math/Line2.js +24 -24
- package/src/og/math/Line3.js +103 -102
- package/src/og/math/Mat3.js +134 -121
- package/src/og/math/Mat4.js +603 -459
- package/src/og/math/Plane.js +21 -20
- package/src/og/math/Quat.js +980 -927
- package/src/og/math/Ray.js +195 -187
- package/src/og/math/Vec2.js +127 -117
- package/src/og/math/Vec3.js +206 -176
- package/src/og/math/Vec4.js +49 -53
- package/src/og/math/coder.js +18 -18
- package/src/og/math.js +12 -12
- package/src/og/mercator.js +11 -11
- package/src/og/proj/EPSG3857.js +4 -4
- package/src/og/proj/EPSG4326.js +4 -4
- package/src/og/proj/Proj.js +31 -31
- package/src/og/quadTree/EntityCollectionNode.js +310 -300
- package/src/og/quadTree/Node.js +1008 -993
- package/src/og/renderer/Renderer.js +768 -747
- package/src/og/renderer/RendererEvents.js +9 -6
- package/src/og/scene/Axes.js +1 -1
- package/src/og/scene/BaseNode.js +8 -9
- package/src/og/scene/Planet.js +115 -87
- package/src/og/scene/RenderNode.js +29 -22
- package/src/og/scene/SkyBox.js +1 -1
- package/src/og/segment/Segment.js +1886 -1878
- package/src/og/segment/SegmentLonLat.js +298 -268
- package/src/og/segment/segmentHelper.js +11 -11
- package/src/og/shaders/bloom.js +1 -1
- package/src/og/shaders/blur.js +2 -2
- package/src/og/shaders/depth.js +1 -1
- package/src/og/shaders/geoObject.js +211 -0
- package/src/og/shaders/label.js +1 -1
- package/src/og/shaders/lumFilter.js +1 -1
- package/src/og/shaders/pointCloud.js +42 -42
- package/src/og/shaders/screenFrame.js +1 -1
- package/src/og/shaders/shape.js +15 -21
- package/src/og/shaders/skybox.js +37 -37
- package/src/og/shaders/toneMapping.js +1 -1
- package/src/og/shapes/BaseShape.js +129 -57
- package/src/og/shapes/Icosphere.js +30 -15
- package/src/og/shapes/Sphere.js +13 -16
- package/src/og/terrain/BilTerrain.js +2 -1
- package/src/og/terrain/EmptyTerrain.js +2 -2
- package/src/og/terrain/Geoid.js +2 -2
- package/src/og/terrain/GlobusTerrain.js +10 -10
- package/src/og/terrain/MapboxTerrain.js +1 -1
- package/src/og/utils/GeoImageCreator.js +9 -9
- package/src/og/utils/Loader.js +6 -6
- package/src/og/utils/NormalMapCreator.js +13 -13
- package/src/og/utils/TerrainWorker.js +1 -1
- package/src/og/utils/TextureAtlas.js +20 -22
- package/src/og/utils/VectorTileCreator.js +5 -5
- package/src/og/utils/earcut.js +1 -1
- package/src/og/utils/shared.js +15 -15
- package/src/og/webgl/Framebuffer.js +101 -53
- package/src/og/webgl/Handler.js +125 -85
- package/src/og/webgl/Multisample.js +55 -27
- package/src/og/webgl/Program.js +80 -35
- package/src/og/webgl/ProgramController.js +27 -23
- package/src/og/webgl/callbacks.js +8 -8
- package/types/Clock.d.ts +6 -2
- package/types/Deferred.d.ts +1 -1
- package/types/Events.d.ts +8 -4
- package/types/Extent.d.ts +37 -33
- package/types/Globe.d.ts +15 -13
- package/types/ImageCanvas.d.ts +5 -3
- package/types/LonLat.d.ts +24 -24
- package/types/Popup.d.ts +4 -0
- package/types/QueueArray.d.ts +6 -2
- package/types/Rectangle.d.ts +10 -4
- package/types/Stack.d.ts +4 -0
- package/types/ajax.d.ts +1 -1
- package/types/astro/earth.d.ts +3 -2
- package/types/bv/Box.d.ts +10 -5
- package/types/bv/Sphere.d.ts +13 -7
- package/types/camera/Camera.d.ts +90 -81
- package/types/camera/Frustum.d.ts +26 -22
- package/types/camera/PlanetCamera.d.ts +49 -53
- package/types/control/CompassButton.d.ts +4 -4
- package/types/control/Control.d.ts +7 -4
- package/types/control/DebugInfo.d.ts +3 -4
- package/types/control/EarthCoordinates.d.ts +6 -6
- package/types/control/EarthNavigation.d.ts +42 -0
- package/types/control/KeyboardNavigation.d.ts +3 -4
- package/types/control/LayerSwitcher.d.ts +3 -5
- package/types/control/Lighting.d.ts +3 -3
- package/types/control/MouseNavigation.d.ts +47 -0
- package/types/control/ScaleControl.d.ts +3 -3
- package/types/control/ShowFps.d.ts +3 -4
- package/types/control/SimpleNavigation.d.ts +3 -6
- package/types/control/Sun.d.ts +8 -10
- package/types/control/ToggleWireframe.d.ts +3 -3
- package/types/control/TouchNavigation.d.ts +48 -0
- package/types/control/ZoomControl.d.ts +3 -4
- package/types/control/index.d.ts +3 -1
- package/types/ellipsoid/Ellipsoid.d.ts +47 -43
- package/types/ellipsoid/wgs84.d.ts +3 -2
- package/types/entity/BaseBillboard.d.ts +41 -34
- package/types/entity/Billboard.d.ts +7 -7
- package/types/entity/BillboardHandler.d.ts +4 -0
- package/types/entity/Entity.d.ts +101 -83
- package/types/entity/EntityCollection.d.ts +57 -43
- package/types/entity/GeoObject.d.ts +111 -0
- package/types/entity/GeoObjectHandler.d.ts +77 -0
- package/types/entity/Geometry.d.ts +9 -7
- package/types/entity/GeometryHandler.d.ts +2 -2
- package/types/entity/Label.d.ts +24 -29
- package/types/entity/LabelHandler.d.ts +9 -2
- package/types/entity/LabelWorker.d.ts +9 -0
- package/types/entity/PointCloud.d.ts +8 -8
- package/types/entity/PointCloudHandler.d.ts +3 -3
- package/types/entity/Polyline.d.ts +58 -55
- package/types/entity/Ray.d.ts +19 -18
- package/types/entity/Strip.d.ts +8 -7
- package/types/entity/StripHandler.d.ts +3 -3
- package/types/entity/index.d.ts +7 -7
- package/types/input/KeyboardHandler.d.ts +10 -0
- package/types/input/MouseHandler.d.ts +5 -0
- package/types/input/TouchHandler.d.ts +5 -0
- package/types/layer/BaseGeoImage.d.ts +23 -35
- package/types/layer/CanvasTiles.d.ts +15 -22
- package/types/layer/GeoImage.d.ts +5 -18
- package/types/layer/GeoVideo.d.ts +5 -30
- package/types/layer/KML.d.ts +20 -15
- package/types/layer/Layer.d.ts +326 -0
- package/types/layer/Material.d.ts +45 -0
- package/types/layer/Vector.d.ts +208 -0
- package/types/layer/WMS.d.ts +4 -7
- package/types/layer/XYZ.d.ts +19 -25
- package/types/light/LightSource.d.ts +54 -53
- package/types/math/Line2.d.ts +11 -0
- package/types/math/Line3.d.ts +10 -0
- package/types/math/Mat3.d.ts +30 -18
- package/types/math/Mat4.d.ts +71 -52
- package/types/math/Plane.d.ts +5 -4
- package/types/math/Quat.d.ts +379 -0
- package/types/math/Ray.d.ts +82 -0
- package/types/math/Vec2.d.ts +102 -101
- package/types/math/Vec3.d.ts +143 -142
- package/types/math/Vec4.d.ts +40 -39
- package/types/math/coder.d.ts +12 -11
- package/types/math.d.ts +8 -8
- package/types/mercator.d.ts +3 -3
- package/types/proj/EPSG3857.d.ts +3 -2
- package/types/proj/EPSG4326.d.ts +3 -2
- package/types/proj/Proj.d.ts +42 -0
- package/types/quadTree/EntityCollectionNode.d.ts +34 -0
- package/types/quadTree/Node.d.ts +61 -0
- package/types/renderer/Renderer.d.ts +300 -0
- package/types/renderer/RendererEvents.d.ts +10 -7
- package/types/scene/BaseNode.d.ts +9 -9
- package/types/scene/Planet.d.ts +131 -126
- package/types/scene/RenderNode.d.ts +22 -23
- package/types/segment/Segment.d.ts +279 -0
- package/types/segment/SegmentLonLat.d.ts +16 -0
- package/types/shaders/geoObject.d.ts +3 -0
- package/types/shapes/BaseShape.d.ts +43 -40
- package/types/shapes/Sphere.d.ts +7 -7
- package/types/terrain/BilTerrain.d.ts +0 -1
- package/types/terrain/EmptyTerrain.d.ts +4 -4
- package/types/terrain/GlobusTerrain.d.ts +17 -54
- package/types/terrain/MapboxTerrain.d.ts +0 -1
- package/types/utils/GeoImageCreator.d.ts +3 -2
- package/types/utils/TextureAtlas.d.ts +8 -8
- package/types/utils/shared.d.ts +25 -24
- package/types/webgl/Framebuffer.d.ts +5 -5
- package/types/webgl/Handler.d.ts +68 -43
- package/types/webgl/Multisample.d.ts +5 -5
- package/types/webgl/Program.d.ts +8 -2
- package/types/webgl/ProgramController.d.ts +18 -13
- package/src/og/inherits.js +0 -8
- package/src/og/utils/polylabel.js +0 -176
- package/types/inherits.d.ts +0 -4
package/src/og/camera/Frustum.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
import { Mat4 } from
|
|
3
|
+
import { Mat4 } from "../math/Mat4.js";
|
|
4
4
|
|
|
5
5
|
function planeNormalize(plane) {
|
|
6
6
|
var t = 1.0 / Math.sqrt(plane[0] * plane[0] + plane[1] * plane[1] + plane[2] * plane[2]);
|
|
@@ -15,6 +15,9 @@ function planeNormalize(plane) {
|
|
|
15
15
|
* @class
|
|
16
16
|
*/
|
|
17
17
|
class Frustum {
|
|
18
|
+
/**
|
|
19
|
+
* @param {*} options
|
|
20
|
+
*/
|
|
18
21
|
constructor(options = {}) {
|
|
19
22
|
/**
|
|
20
23
|
* Frustum planes.
|
|
@@ -29,28 +32,28 @@ class Frustum {
|
|
|
29
32
|
/**
|
|
30
33
|
* Camera projection matrix.
|
|
31
34
|
* @protected
|
|
32
|
-
* @type {
|
|
35
|
+
* @type {Mat4}
|
|
33
36
|
*/
|
|
34
37
|
this._projectionMatrix = new Mat4();
|
|
35
38
|
|
|
36
39
|
/**
|
|
37
40
|
* Camera inverse projection matrix.
|
|
38
41
|
* @protected
|
|
39
|
-
* @type {
|
|
42
|
+
* @type {Mat4}
|
|
40
43
|
*/
|
|
41
44
|
this._inverseProjectionMatrix = new Mat4();
|
|
42
45
|
|
|
43
46
|
/**
|
|
44
47
|
* Product of projection and view matrices.
|
|
45
48
|
* @protected
|
|
46
|
-
* @type {
|
|
49
|
+
* @type {Mat4}
|
|
47
50
|
*/
|
|
48
51
|
this._projectionViewMatrix = new Mat4();
|
|
49
52
|
|
|
50
53
|
/**
|
|
51
54
|
* Inverse projectionView Matrix.
|
|
52
55
|
* @protected
|
|
53
|
-
* @type {
|
|
56
|
+
* @type {Mat4}
|
|
54
57
|
*/
|
|
55
58
|
this._inverseProjectionViewMatrix = new Mat4();
|
|
56
59
|
|
|
@@ -85,7 +88,8 @@ class Frustum {
|
|
|
85
88
|
*/
|
|
86
89
|
this.far = 0.0;
|
|
87
90
|
|
|
88
|
-
this._cameraFrustumIndex =
|
|
91
|
+
this._cameraFrustumIndex =
|
|
92
|
+
options.cameraFrustumIndex != undefined ? options.cameraFrustumIndex : -1;
|
|
89
93
|
|
|
90
94
|
this.setProjectionMatrix(
|
|
91
95
|
options.fov || 30.0,
|
|
@@ -140,15 +144,21 @@ class Frustum {
|
|
|
140
144
|
* @param {number} far - Far camera distance.
|
|
141
145
|
*/
|
|
142
146
|
setProjectionMatrix(angle, aspect, near, far) {
|
|
143
|
-
|
|
144
|
-
this.top = near * Math.tan(angle * Math.PI / 360);
|
|
147
|
+
this.top = near * Math.tan((angle * Math.PI) / 360);
|
|
145
148
|
this.bottom = -this.top;
|
|
146
149
|
this.right = this.top * aspect;
|
|
147
150
|
this.left = -this.right;
|
|
148
151
|
this.near = near;
|
|
149
152
|
this.far = far;
|
|
150
153
|
|
|
151
|
-
this._projectionMatrix.setPerspective(
|
|
154
|
+
this._projectionMatrix.setPerspective(
|
|
155
|
+
this.left,
|
|
156
|
+
this.right,
|
|
157
|
+
this.bottom,
|
|
158
|
+
this.top,
|
|
159
|
+
near,
|
|
160
|
+
far
|
|
161
|
+
);
|
|
152
162
|
this._projectionMatrix.inverseTo(this._inverseProjectionMatrix);
|
|
153
163
|
}
|
|
154
164
|
|
|
@@ -158,7 +168,6 @@ class Frustum {
|
|
|
158
168
|
* @param {Mat4} projectionView - projectionView matrix.
|
|
159
169
|
*/
|
|
160
170
|
setViewMatrix(viewMatrix) {
|
|
161
|
-
|
|
162
171
|
this._projectionViewMatrix = this._projectionMatrix.mul(viewMatrix);
|
|
163
172
|
this._projectionViewMatrix.inverseTo(this._inverseProjectionViewMatrix);
|
|
164
173
|
|
|
@@ -210,7 +219,7 @@ class Frustum {
|
|
|
210
219
|
/**
|
|
211
220
|
* Returns true if a point in the frustum.
|
|
212
221
|
* @public
|
|
213
|
-
* @param {
|
|
222
|
+
* @param {Vec3} point - Cartesian point.
|
|
214
223
|
* @returns {boolean} -
|
|
215
224
|
*/
|
|
216
225
|
containsPoint(point) {
|
|
@@ -227,7 +236,7 @@ class Frustum {
|
|
|
227
236
|
/**
|
|
228
237
|
* Returns true if the frustum contains a bonding sphere, but bottom plane exclude.
|
|
229
238
|
* @public
|
|
230
|
-
* @param {
|
|
239
|
+
* @param {Sphere} sphere - Bounding sphere.
|
|
231
240
|
* @returns {boolean} -
|
|
232
241
|
*/
|
|
233
242
|
containsSphereBottomExc(sphere) {
|
|
@@ -251,7 +260,7 @@ class Frustum {
|
|
|
251
260
|
/**
|
|
252
261
|
* Returns true if the frustum contains a bonding sphere.
|
|
253
262
|
* @public
|
|
254
|
-
* @param {
|
|
263
|
+
* @param {Sphere} sphere - Bounding sphere.
|
|
255
264
|
* @returns {boolean} -
|
|
256
265
|
*/
|
|
257
266
|
containsSphere(sphere) {
|
|
@@ -287,15 +296,17 @@ class Frustum {
|
|
|
287
296
|
/**
|
|
288
297
|
* Returns true if the frustum contains a bounding box.
|
|
289
298
|
* @public
|
|
290
|
-
* @param {
|
|
299
|
+
* @param {Box} box - Bounding box.
|
|
291
300
|
* @returns {boolean} -
|
|
292
301
|
*/
|
|
293
302
|
containsBox(box) {
|
|
294
|
-
var result = true,
|
|
303
|
+
var result = true,
|
|
304
|
+
cout,
|
|
305
|
+
cin;
|
|
295
306
|
|
|
296
307
|
for (var i = 0; i < 6; i++) {
|
|
297
|
-
|
|
298
|
-
|
|
308
|
+
cout = 0;
|
|
309
|
+
cin = 0;
|
|
299
310
|
|
|
300
311
|
for (var k = 0; k < 8 && (cin === 0 || cout === 0); k++) {
|
|
301
312
|
var d = box.vertices[k].dotArr(this._f[i]) + this._f[i][3];
|
|
@@ -315,6 +326,6 @@ class Frustum {
|
|
|
315
326
|
|
|
316
327
|
return result;
|
|
317
328
|
}
|
|
318
|
-
}
|
|
329
|
+
}
|
|
319
330
|
|
|
320
331
|
export { Frustum };
|
|
@@ -17,8 +17,8 @@ import { Mat4 } from "../math/Mat4.js";
|
|
|
17
17
|
/**
|
|
18
18
|
* Planet camera.
|
|
19
19
|
* @class
|
|
20
|
-
* @extends {
|
|
21
|
-
* @param {
|
|
20
|
+
* @extends {Camera}
|
|
21
|
+
* @param {RenderNode} planet - Planet render node.
|
|
22
22
|
* @param {Object} [options] - Planet camera options:
|
|
23
23
|
* @param {Object} [options.name] - Camera name.
|
|
24
24
|
* @param {number} [options.viewAngle=37] - Camera angle of view. Default is 35.0
|
|
@@ -26,11 +26,15 @@ import { Mat4 } from "../math/Mat4.js";
|
|
|
26
26
|
* @param {number} [options.far] - Camera far plane distance. Deafult is og.math.MAX
|
|
27
27
|
* @param {number} [options.minAltitude] - Minimal altitude for the camera. Deafult is 1
|
|
28
28
|
* @param {number} [options.maxAltitude] - Maximal altitude for the camera. Deafult is 20000000
|
|
29
|
-
* @param {
|
|
30
|
-
* @param {
|
|
31
|
-
* @param {
|
|
29
|
+
* @param {Vec3} [options.eye] - Camera eye position. Default (0,0,0)
|
|
30
|
+
* @param {Vec3} [options.look] - Camera look position. Default (0,0,0)
|
|
31
|
+
* @param {Vec3} [options.up] - Camera eye position. Default (0,1,0)
|
|
32
32
|
*/
|
|
33
33
|
class PlanetCamera extends Camera {
|
|
34
|
+
/**
|
|
35
|
+
* @param {RenderNode} planet - Planet render node.
|
|
36
|
+
* @param {Object} [options] - Planet camera options:
|
|
37
|
+
*/
|
|
34
38
|
constructor(planet, options) {
|
|
35
39
|
super(
|
|
36
40
|
planet.renderer,
|
|
@@ -50,7 +54,7 @@ class PlanetCamera extends Camera {
|
|
|
50
54
|
/**
|
|
51
55
|
* Assigned camera's planet.
|
|
52
56
|
* @public
|
|
53
|
-
* @type {
|
|
57
|
+
* @type {Planet}
|
|
54
58
|
*/
|
|
55
59
|
this.planet = planet;
|
|
56
60
|
|
|
@@ -71,14 +75,14 @@ class PlanetCamera extends Camera {
|
|
|
71
75
|
/**
|
|
72
76
|
* Current geographical degree position.
|
|
73
77
|
* @protected
|
|
74
|
-
* @type {
|
|
78
|
+
* @type {LonLat}
|
|
75
79
|
*/
|
|
76
80
|
this._lonLat = this.planet.ellipsoid.cartesianToLonLat(this.eye);
|
|
77
81
|
|
|
78
82
|
/**
|
|
79
83
|
* Current geographical mercator position.
|
|
80
84
|
* @protected
|
|
81
|
-
* @type {
|
|
85
|
+
* @type {LonLat}
|
|
82
86
|
*/
|
|
83
87
|
this._lonLatMerc = this._lonLat.forwardMercator();
|
|
84
88
|
|
|
@@ -92,14 +96,14 @@ class PlanetCamera extends Camera {
|
|
|
92
96
|
/**
|
|
93
97
|
* Cartesian coordinates on the terrain.
|
|
94
98
|
* @protected
|
|
95
|
-
* @type {
|
|
99
|
+
* @type {Vec3}
|
|
96
100
|
*/
|
|
97
101
|
this._terrainPoint = new Vec3();
|
|
98
102
|
|
|
99
103
|
/**
|
|
100
104
|
* Quad node that camera flies over.
|
|
101
105
|
* @protected
|
|
102
|
-
* @type {
|
|
106
|
+
* @type {quadTree.Node}
|
|
103
107
|
*/
|
|
104
108
|
this._insideSegment = null;
|
|
105
109
|
|
|
@@ -107,7 +111,7 @@ class PlanetCamera extends Camera {
|
|
|
107
111
|
* Coordinates that depends on what segment class we are fling over.
|
|
108
112
|
* It can be WGS84 or Mercator coordinates. Gets in og.quadTree.Node
|
|
109
113
|
* @protected
|
|
110
|
-
* @type {
|
|
114
|
+
* @type {LonLat}
|
|
111
115
|
*/
|
|
112
116
|
this._insideSegmentPosition = new LonLat();
|
|
113
117
|
|
|
@@ -176,9 +180,9 @@ class PlanetCamera extends Camera {
|
|
|
176
180
|
/**
|
|
177
181
|
* Places camera to view to the geographical point.
|
|
178
182
|
* @public
|
|
179
|
-
* @param {
|
|
180
|
-
* @param {
|
|
181
|
-
* @param {
|
|
183
|
+
* @param {LonLat} lonlat - New camera and camera view position.
|
|
184
|
+
* @param {LonLat} [lookLonLat] - Look up coordinates.
|
|
185
|
+
* @param {Vec3} [up] - Camera UP vector. Default (0,1,0)
|
|
182
186
|
*/
|
|
183
187
|
setLonLat(lonlat, lookLonLat, up) {
|
|
184
188
|
this.stopFlying();
|
|
@@ -193,7 +197,7 @@ class PlanetCamera extends Camera {
|
|
|
193
197
|
/**
|
|
194
198
|
* Returns camera geographical position.
|
|
195
199
|
* @public
|
|
196
|
-
* @returns {
|
|
200
|
+
* @returns {LonLat}
|
|
197
201
|
*/
|
|
198
202
|
getLonLat() {
|
|
199
203
|
return this._lonLat;
|
|
@@ -211,9 +215,9 @@ class PlanetCamera extends Camera {
|
|
|
211
215
|
/**
|
|
212
216
|
* Gets position by viewable extent.
|
|
213
217
|
* @public
|
|
214
|
-
* @param {
|
|
218
|
+
* @param {Extent} extent - Viewable extent.
|
|
215
219
|
* @param {Number} height - Camera height
|
|
216
|
-
* @returns {
|
|
220
|
+
* @returns {Vec3}
|
|
217
221
|
*/
|
|
218
222
|
getExtentPosition(extent, height) {
|
|
219
223
|
var north = extent.getNorth();
|
|
@@ -281,7 +285,7 @@ class PlanetCamera extends Camera {
|
|
|
281
285
|
/**
|
|
282
286
|
* View current extent.
|
|
283
287
|
* @public
|
|
284
|
-
* @param {
|
|
288
|
+
* @param {Extent} extent - Current extent.
|
|
285
289
|
*/
|
|
286
290
|
viewExtent(extent, height) {
|
|
287
291
|
this.stopFlying();
|
|
@@ -292,8 +296,8 @@ class PlanetCamera extends Camera {
|
|
|
292
296
|
/**
|
|
293
297
|
* Flies to the current extent.
|
|
294
298
|
* @public
|
|
295
|
-
* @param {
|
|
296
|
-
* @param {
|
|
299
|
+
* @param {Extent} extent - Current extent.
|
|
300
|
+
* @param {Vec3} [up] - Camera UP in the end of flying. Default - (0,1,0)
|
|
297
301
|
* @param {Number} [ampl] - Altitude amplitude factor.
|
|
298
302
|
* @param {cameraCallback} [completeCallback] - Callback that calls after flying when flying is finished.
|
|
299
303
|
* @param {cameraCallback} [startCallback] - Callback that calls befor the flying begins.
|
|
@@ -356,9 +360,9 @@ class PlanetCamera extends Camera {
|
|
|
356
360
|
/**
|
|
357
361
|
* Flies to the cartesian coordinates.
|
|
358
362
|
* @public
|
|
359
|
-
* @param {
|
|
360
|
-
* @param {
|
|
361
|
-
* @param {
|
|
363
|
+
* @param {Vec3} cartesian - Finish cartesian coordinates.
|
|
364
|
+
* @param {Vec3} [look] - Camera LOOK in the end of flying. Default - (0,0,0)
|
|
365
|
+
* @param {Vec3} [up] - Camera UP vector in the end of flying. Default - (0,1,0)
|
|
362
366
|
* @param {Number} [ampl=1.0] - Altitude amplitude factor.
|
|
363
367
|
* @param {cameraCallback} [completeCallback] - Callback that calls after flying when flying is finished.
|
|
364
368
|
* @param {cameraCallback} [startCallback] - Callback that calls befor the flying begins.
|
|
@@ -452,9 +456,9 @@ class PlanetCamera extends Camera {
|
|
|
452
456
|
/**
|
|
453
457
|
* Flies to the geo coordiantes.
|
|
454
458
|
* @public
|
|
455
|
-
* @param {
|
|
456
|
-
* @param {
|
|
457
|
-
* @param {
|
|
459
|
+
* @param {LonLat} lonlat - Finish coordinates.
|
|
460
|
+
* @param {Vec3} [look] - Camera LOOK in the end of flying. Default - (0,0,0)
|
|
461
|
+
* @param {Vec3} [up] - Camera UP vector in the end of flying. Default - (0,1,0)
|
|
458
462
|
* @param {Number} [ampl] - Altitude amplitude factor.
|
|
459
463
|
* @param {cameraCallback} [completeCallback] - Callback that calls after flying when flying is finished.
|
|
460
464
|
* @param {cameraCallback} [startCallback] - Callback that calls befor the flying begins.
|
|
@@ -82,10 +82,14 @@ let svg = `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
|
82
82
|
/**
|
|
83
83
|
* Planet compass button
|
|
84
84
|
* @class
|
|
85
|
-
* @extends {
|
|
85
|
+
* @extends {Control}
|
|
86
86
|
* @params {Object} [options] - Control options.
|
|
87
87
|
*/
|
|
88
88
|
class CompassButton extends Control {
|
|
89
|
+
/**
|
|
90
|
+
*
|
|
91
|
+
* @params {Object} [options] - Control options.
|
|
92
|
+
*/
|
|
89
93
|
constructor(options) {
|
|
90
94
|
super(options);
|
|
91
95
|
|
|
@@ -93,13 +97,15 @@ class CompassButton extends Control {
|
|
|
93
97
|
|
|
94
98
|
this.planet = null;
|
|
95
99
|
|
|
100
|
+
this.compassSvg = options.compassSvg || svg;
|
|
101
|
+
|
|
96
102
|
this._heading = null;
|
|
97
103
|
|
|
98
104
|
this._svg = null;
|
|
99
105
|
}
|
|
100
106
|
|
|
101
107
|
oninit() {
|
|
102
|
-
var btnEl = parseHTML(`<div class="og-compass-button">${
|
|
108
|
+
var btnEl = parseHTML(`<div class="og-compass-button">${this.compassSvg}</div>`)[0];
|
|
103
109
|
|
|
104
110
|
this._svg = btnEl.querySelector("svg");
|
|
105
111
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @module og/control/Control
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
"use strict";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Base control class for implementing renderer controls.
|
|
@@ -12,6 +12,9 @@
|
|
|
12
12
|
* @param {Boolean} [options.autoActivated=true] - If true - calls initialize function after the renderer assigning.
|
|
13
13
|
*/
|
|
14
14
|
class Control {
|
|
15
|
+
/**
|
|
16
|
+
* @param {Object} [options] - Control activation options:
|
|
17
|
+
*/
|
|
15
18
|
constructor(options) {
|
|
16
19
|
options = options || {};
|
|
17
20
|
|
|
@@ -29,7 +32,7 @@ class Control {
|
|
|
29
32
|
/**
|
|
30
33
|
* Assigned renderer.
|
|
31
34
|
* @public
|
|
32
|
-
* @type {
|
|
35
|
+
* @type {Renderer}
|
|
33
36
|
*/
|
|
34
37
|
this.renderer = null;
|
|
35
38
|
|
|
@@ -73,40 +76,40 @@ class Control {
|
|
|
73
76
|
* @public
|
|
74
77
|
* @virtual
|
|
75
78
|
*/
|
|
76
|
-
oninit() {
|
|
79
|
+
oninit() {}
|
|
77
80
|
|
|
78
81
|
/**
|
|
79
82
|
* Control renderer assigning function have to be overriden.
|
|
80
83
|
* @public
|
|
81
84
|
* @virtual
|
|
82
85
|
*/
|
|
83
|
-
onadd() {
|
|
86
|
+
onadd() {}
|
|
84
87
|
|
|
85
88
|
/**
|
|
86
89
|
* Control remove function have to be overriden.
|
|
87
90
|
* @public
|
|
88
91
|
* @virtual
|
|
89
92
|
*/
|
|
90
|
-
onremove() {
|
|
93
|
+
onremove() {}
|
|
91
94
|
|
|
92
95
|
/**
|
|
93
96
|
* Control activation function have to be overriden.
|
|
94
97
|
* @public
|
|
95
98
|
* @virtual
|
|
96
99
|
*/
|
|
97
|
-
onactivate() {
|
|
100
|
+
onactivate() {}
|
|
98
101
|
|
|
99
102
|
/**
|
|
100
103
|
* Control deactivation function have to be overriden.
|
|
101
104
|
* @public
|
|
102
105
|
* @virtual
|
|
103
106
|
*/
|
|
104
|
-
ondeactivate() {
|
|
107
|
+
ondeactivate() {}
|
|
105
108
|
|
|
106
109
|
/**
|
|
107
110
|
* Assign renderer to the control.
|
|
108
111
|
* @public
|
|
109
|
-
* @type {
|
|
112
|
+
* @type {Renderer}
|
|
110
113
|
*/
|
|
111
114
|
addTo(renderer) {
|
|
112
115
|
if (renderer) {
|
|
@@ -126,7 +129,6 @@ class Control {
|
|
|
126
129
|
* @public
|
|
127
130
|
*/
|
|
128
131
|
remove() {
|
|
129
|
-
|
|
130
132
|
this.onremove && this.onremove();
|
|
131
133
|
|
|
132
134
|
let r = this.renderer,
|
|
@@ -181,6 +183,6 @@ class Control {
|
|
|
181
183
|
isEqual(control) {
|
|
182
184
|
return control._id === this._id;
|
|
183
185
|
}
|
|
184
|
-
}
|
|
186
|
+
}
|
|
185
187
|
|
|
186
|
-
export { Control };
|
|
188
|
+
export { Control };
|
|
@@ -9,10 +9,13 @@ import { Control } from "./Control.js";
|
|
|
9
9
|
/**
|
|
10
10
|
* Debug information
|
|
11
11
|
* @class
|
|
12
|
-
* @extends {
|
|
12
|
+
* @extends {Control}
|
|
13
13
|
* @param {Object} [options] - Control options.
|
|
14
14
|
*/
|
|
15
15
|
class DebugInfo extends Control {
|
|
16
|
+
/**
|
|
17
|
+
* @param {Object} [options] - Control options.
|
|
18
|
+
*/
|
|
16
19
|
constructor(options) {
|
|
17
20
|
options = options || {};
|
|
18
21
|
if (!options.name || options.name === "") {
|
|
@@ -2,58 +2,63 @@
|
|
|
2
2
|
* @module og/control/EarthCoordinates
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
"use strict";
|
|
6
6
|
|
|
7
|
-
import { Control } from
|
|
7
|
+
import { Control } from "./Control.js";
|
|
8
8
|
|
|
9
9
|
function dec2deg(base) {
|
|
10
10
|
var t;
|
|
11
11
|
var degrees = base < 0 ? Math.ceil(base) : Math.floor(base);
|
|
12
|
-
var minutes = Math.floor(t = Math.abs(
|
|
12
|
+
var minutes = Math.floor((t = Math.abs(base - degrees) * 60));
|
|
13
13
|
var seconds = Math.floor((t - minutes) * 6000);
|
|
14
|
-
seconds = seconds / 100.
|
|
15
|
-
return (
|
|
16
|
-
numToFixedString(
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
seconds = seconds / 100.0;
|
|
15
|
+
return (
|
|
16
|
+
numToFixedString(degrees, 3) +
|
|
17
|
+
"\u00B0" +
|
|
18
|
+
numToFixedString(minutes, 2) +
|
|
19
|
+
"\u0027" +
|
|
20
|
+
numToFixedString(seconds.toFixed(2), 2) +
|
|
21
|
+
"\u0022"
|
|
22
|
+
);
|
|
23
|
+
}
|
|
19
24
|
|
|
20
25
|
function numToFixedString(num, fixed) {
|
|
21
|
-
var dl = num.toString().split(
|
|
26
|
+
var dl = num.toString().split(".")[0].length;
|
|
22
27
|
var white = " ";
|
|
23
28
|
for (var i = dl; i < fixed; i++) {
|
|
24
|
-
white +=
|
|
29
|
+
white += " ";
|
|
25
30
|
}
|
|
26
31
|
return white + num.toString();
|
|
27
|
-
}
|
|
32
|
+
}
|
|
28
33
|
|
|
29
34
|
function toDecimal(ll) {
|
|
30
35
|
return ll.lat.toFixed(5) + ", " + ll.lon.toFixed(5);
|
|
31
|
-
}
|
|
36
|
+
}
|
|
32
37
|
|
|
33
38
|
function toDegrees(ll) {
|
|
34
39
|
return dec2deg(ll.lat) + ", " + dec2deg(ll.lon);
|
|
35
|
-
}
|
|
40
|
+
}
|
|
36
41
|
|
|
37
42
|
function toMercator(ll) {
|
|
38
43
|
var m = ll.forwardMercator();
|
|
39
44
|
return m.lat.toFixed(5) + ", " + m.lon.toFixed(5);
|
|
40
|
-
}
|
|
45
|
+
}
|
|
41
46
|
|
|
42
|
-
const DisplayTypesConverters = [
|
|
43
|
-
toDecimal,
|
|
44
|
-
toDegrees,
|
|
45
|
-
toMercator
|
|
46
|
-
];
|
|
47
|
+
const DisplayTypesConverters = [toDecimal, toDegrees, toMercator];
|
|
47
48
|
|
|
48
49
|
/**
|
|
49
50
|
* Control displays mouse or screen center Earth coordinates.
|
|
50
51
|
* @class
|
|
51
|
-
* @extends {
|
|
52
|
+
* @extends {Control}
|
|
52
53
|
* @param {Object} [options] - Options:
|
|
53
54
|
* @param {Boolean} [options.center] - Earth coordiantes by screen center otherwise mouse pointer. False is default.
|
|
54
55
|
* @param {Boolean} [options.type] - Coordinates shown: 0 - is decimal degrees, 1 - degrees, 2 - mercator geodetic coordinates.
|
|
55
56
|
*/
|
|
56
57
|
class EarthCoordinates extends Control {
|
|
58
|
+
/**
|
|
59
|
+
*
|
|
60
|
+
* @param {Object} [options] - Options:
|
|
61
|
+
*/
|
|
57
62
|
constructor(options) {
|
|
58
63
|
super(options);
|
|
59
64
|
|
|
@@ -87,27 +92,32 @@ class EarthCoordinates extends Control {
|
|
|
87
92
|
*/
|
|
88
93
|
|
|
89
94
|
var pad = false;
|
|
90
|
-
if (
|
|
95
|
+
if (
|
|
96
|
+
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
|
|
97
|
+
navigator.userAgent
|
|
98
|
+
)
|
|
99
|
+
) {
|
|
91
100
|
pad = true;
|
|
92
101
|
}
|
|
93
102
|
|
|
94
103
|
this._center = options.center || pad;
|
|
95
104
|
|
|
105
|
+
this._centerDiv = null;
|
|
106
|
+
|
|
96
107
|
/**
|
|
97
108
|
* Current position.
|
|
98
109
|
* @public
|
|
99
|
-
* @type {
|
|
110
|
+
* @type {Vec3}
|
|
100
111
|
*/
|
|
101
112
|
this.position = null;
|
|
102
113
|
}
|
|
103
114
|
|
|
104
115
|
oninit() {
|
|
105
|
-
this._display = document.createElement(
|
|
106
|
-
this._display.className =
|
|
116
|
+
this._display = document.createElement("div");
|
|
117
|
+
this._display.className = "ogEarthCoordinatesControl";
|
|
107
118
|
var that = this;
|
|
108
119
|
|
|
109
120
|
function _refresh(el) {
|
|
110
|
-
|
|
111
121
|
if (that._displayType >= DisplayTypesConverters.length) {
|
|
112
122
|
that._displayType = 0;
|
|
113
123
|
}
|
|
@@ -121,7 +131,7 @@ class EarthCoordinates extends Control {
|
|
|
121
131
|
}
|
|
122
132
|
that._converter = DisplayTypesConverters[that._displayType];
|
|
123
133
|
that._showPosition();
|
|
124
|
-
}
|
|
134
|
+
}
|
|
125
135
|
|
|
126
136
|
this._display.onclick = function (e) {
|
|
127
137
|
that._displayType += 1;
|
|
@@ -132,19 +142,19 @@ class EarthCoordinates extends Control {
|
|
|
132
142
|
|
|
133
143
|
_refresh(this._display);
|
|
134
144
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
145
|
+
this._centerDiv = document.createElement("div");
|
|
146
|
+
this._centerDiv.className = "ogCenterIcon";
|
|
147
|
+
this._centerDiv.innerHTML =
|
|
148
|
+
'<svg width="12" height="12"><g><path stroke-width="1" stroke-opacity="1" d="M6 0L6 12M0 6L12 6" stroke="#009DFF"></path></g></svg>';
|
|
149
|
+
this.renderer.div.appendChild(this._centerDiv);
|
|
139
150
|
|
|
140
151
|
if (this._center) {
|
|
141
152
|
this.renderer.activeCamera.events.on("moveend", this._grabCoordinates, this);
|
|
142
|
-
|
|
153
|
+
this._centerDiv.style.display = "block";
|
|
143
154
|
} else {
|
|
144
155
|
this.renderer.events.on("mousemove", this._onMouseMove, this);
|
|
145
|
-
|
|
156
|
+
this._centerDiv.style.display = "none";
|
|
146
157
|
}
|
|
147
|
-
|
|
148
158
|
}
|
|
149
159
|
|
|
150
160
|
/**
|
|
@@ -158,19 +168,28 @@ class EarthCoordinates extends Control {
|
|
|
158
168
|
if (center) {
|
|
159
169
|
this.renderer.events.off("mousemove", this._onMouseMove);
|
|
160
170
|
this.renderer.activeCamera.events.on("moveend", this._grabCoordinates, this);
|
|
161
|
-
|
|
171
|
+
this._centerDiv.style.display = "block";
|
|
162
172
|
} else {
|
|
163
173
|
this.renderer.events.off("draw", this._draw);
|
|
164
174
|
this.renderer.events.on("mousemove", this._onMouseMove, this);
|
|
165
|
-
|
|
175
|
+
this._centerDiv.style.display = "none";
|
|
166
176
|
}
|
|
167
177
|
}
|
|
168
178
|
}
|
|
169
179
|
|
|
170
180
|
_showPosition() {
|
|
171
181
|
if (this.position) {
|
|
172
|
-
this.position.height =
|
|
173
|
-
|
|
182
|
+
this.position.height =
|
|
183
|
+
this.position.height > 10000 || this.position.height < -10000
|
|
184
|
+
? 0
|
|
185
|
+
: this.position.height;
|
|
186
|
+
this._display.innerHTML =
|
|
187
|
+
"Lat/Lon: " +
|
|
188
|
+
this._converter(this.position) +
|
|
189
|
+
" h(m): " +
|
|
190
|
+
(this.position.height > 0
|
|
191
|
+
? "~" + (Math.round(this.position.height) / 1000).toFixed(3) * 1000
|
|
192
|
+
: "-");
|
|
174
193
|
} else {
|
|
175
194
|
this._display.innerHTML = "Lat/Lon: " + "_____________________";
|
|
176
195
|
}
|
|
@@ -185,17 +204,19 @@ class EarthCoordinates extends Control {
|
|
|
185
204
|
_onMouseMove() {
|
|
186
205
|
var r = this.renderer;
|
|
187
206
|
var ms = r.events.mouseState;
|
|
188
|
-
if (
|
|
207
|
+
if (
|
|
208
|
+
!(ms.leftButtonDown || ms.rightButtonDown) &&
|
|
189
209
|
r.controlsBag.scaleRot <= 0 &&
|
|
190
|
-
!r.activeCamera._flying
|
|
210
|
+
!r.activeCamera._flying
|
|
211
|
+
) {
|
|
191
212
|
this.position = this.planet.getLonLatFromPixelTerrain(ms, true);
|
|
192
213
|
this._showPosition();
|
|
193
214
|
}
|
|
194
215
|
}
|
|
195
|
-
}
|
|
216
|
+
}
|
|
196
217
|
|
|
197
218
|
export function earthCoordinates(options) {
|
|
198
219
|
return new EarthCoordinates(options);
|
|
199
|
-
}
|
|
220
|
+
}
|
|
200
221
|
|
|
201
222
|
export { EarthCoordinates };
|