@openglobus/og 0.10.4 → 0.11.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.
- package/css/og.css +1 -1
- package/package.json +11 -9
- package/src/og/Extent.js +274 -273
- package/src/og/Globe.js +11 -3
- package/src/og/LonLat.js +152 -146
- package/src/og/Popup.js +2 -1
- package/src/og/camera/PlanetCamera.js +112 -38
- package/src/og/control/EarthNavigation.js +259 -0
- package/src/og/control/MouseNavigation.js +68 -40
- package/src/og/entity/EntityCollection.js +1 -1
- package/src/og/entity/LabelHandler.js +366 -74
- package/src/og/entity/Polyline.js +3 -2
- package/src/og/layer/CanvasTiles.js +32 -30
- package/src/og/layer/KML.js +159 -0
- package/src/og/layer/Vector.js +5 -0
- package/src/og/layer/index.js +2 -1
- package/src/og/math/Vec2.js +448 -448
- package/src/og/math/Vec3.js +759 -757
- package/src/og/math/Vec4.js +216 -215
- package/src/og/quadTree/Node.js +67 -13
- package/src/og/renderer/RendererEvents.js +21 -16
- package/src/og/scene/Planet.js +25 -10
- package/src/og/segment/Segment.js +3 -3
- package/src/og/segment/SegmentLonLat.js +7 -0
- package/src/og/terrain/GlobusTerrain.js +4 -0
- package/src/og/utils/FontAtlas.js +1 -0
- package/src/og/utils/GeoImageCreator.js +123 -121
- package/src/og/utils/Loader.js +81 -80
- package/src/og/utils/NormalMapCreator.js +320 -318
- package/src/og/utils/VectorTileCreator.js +251 -250
- package/src/og/webgl/Framebuffer.js +265 -264
- package/src/og/webgl/Handler.js +1022 -1001
- package/src/og/webgl/Multisample.js +169 -168
- package/src/og/webgl/ProgramController.js +113 -112
- package/types/Clock.d.ts +90 -0
- package/types/Deferred.d.ts +6 -0
- package/types/Events.d.ts +73 -0
- package/types/Extent.d.ts +162 -0
- package/types/Globe.d.ts +80 -0
- package/types/ImageCanvas.d.ts +121 -0
- package/types/Lock.d.ts +12 -0
- package/types/LonLat.d.ts +108 -0
- package/types/Popup.d.ts +38 -0
- package/types/QueueArray.d.ts +15 -0
- package/types/Rectangle.d.ts +74 -0
- package/types/Stack.d.ts +15 -0
- package/types/ajax.d.ts +24 -0
- package/types/arial.d.ts +48 -0
- package/types/astro/astro.d.ts +38 -0
- package/types/astro/earth.d.ts +6 -0
- package/types/astro/jd.d.ts +254 -0
- package/types/bv/Box.d.ts +25 -0
- package/types/bv/Sphere.d.ts +32 -0
- package/types/bv/index.d.ts +3 -0
- package/types/camera/Camera.d.ts +303 -0
- package/types/camera/Frustum.d.ts +129 -0
- package/types/camera/PlanetCamera.d.ts +222 -0
- package/types/camera/index.d.ts +3 -0
- package/types/cons.d.ts +40 -0
- package/types/control/CompassButton.d.ts +17 -0
- package/types/control/Control.d.ts +101 -0
- package/types/control/DebugInfo.d.ts +16 -0
- package/types/control/EarthCoordinates.d.ts +47 -0
- package/types/control/GeoImageDragControl.d.ts +6 -0
- package/types/control/KeyboardNavigation.d.ts +22 -0
- package/types/control/LayerSwitcher.d.ts +23 -0
- package/types/control/Lighting.d.ts +16 -0
- package/types/control/ScaleControl.d.ts +22 -0
- package/types/control/ShowFps.d.ts +12 -0
- package/types/control/SimpleNavigation.d.ts +28 -0
- package/types/control/Sun.d.ts +52 -0
- package/types/control/ToggleWireframe.d.ts +12 -0
- package/types/control/ZoomControl.d.ts +28 -0
- package/types/control/index.d.ts +15 -0
- package/types/ellipsoid/Ellipsoid.d.ts +142 -0
- package/types/ellipsoid/index.d.ts +3 -0
- package/types/ellipsoid/wgs84.d.ts +5 -0
- package/types/entity/BaseBillboard.d.ts +208 -0
- package/types/entity/Billboard.d.ts +94 -0
- package/types/entity/BillboardHandler.d.ts +74 -0
- package/types/entity/Entity.d.ts +330 -0
- package/types/entity/EntityCollection.d.ts +303 -0
- package/types/entity/Geometry.d.ts +72 -0
- package/types/entity/GeometryHandler.d.ts +76 -0
- package/types/entity/Label.d.ts +194 -0
- package/types/entity/LabelHandler.d.ts +24 -0
- package/types/entity/PointCloud.d.ts +174 -0
- package/types/entity/PointCloudHandler.d.ts +38 -0
- package/types/entity/Polyline.d.ts +303 -0
- package/types/entity/PolylineHandler.d.ts +18 -0
- package/types/entity/Ray.d.ts +123 -0
- package/types/entity/RayHandler.d.ts +67 -0
- package/types/entity/ShapeHandler.d.ts +22 -0
- package/types/entity/Strip.d.ts +118 -0
- package/types/entity/StripHandler.d.ts +38 -0
- package/types/entity/index.d.ts +8 -0
- package/types/index.core.d.ts +65 -0
- package/types/index.d.ts +45 -0
- package/types/index.webgl.d.ts +7 -0
- package/types/inherits.d.ts +4 -0
- package/types/input/input.d.ts +34 -0
- package/types/layer/BaseGeoImage.d.ts +106 -0
- package/types/layer/CanvasTiles.d.ts +75 -0
- package/types/layer/GeoImage.d.ts +65 -0
- package/types/layer/GeoTexture2d.d.ts +8 -0
- package/types/layer/GeoVideo.d.ts +80 -0
- package/types/layer/KML.d.ts +58 -0
- package/types/layer/WMS.d.ts +66 -0
- package/types/layer/XYZ.d.ts +126 -0
- package/types/layer/index.d.ts +10 -0
- package/types/light/LightSource.d.ts +177 -0
- package/types/math/Mat3.d.ts +53 -0
- package/types/math/Mat4.d.ts +157 -0
- package/types/math/Plane.d.ts +17 -0
- package/types/math/Vec2.d.ts +308 -0
- package/types/math/Vec3.d.ts +459 -0
- package/types/math/Vec4.d.ts +161 -0
- package/types/math/coder.d.ts +42 -0
- package/types/math/index.d.ts +11 -0
- package/types/math.d.ts +261 -0
- package/types/mercator.d.ts +92 -0
- package/types/proj/EPSG3857.d.ts +5 -0
- package/types/proj/EPSG4326.d.ts +5 -0
- package/types/quadTree/quadTree.d.ts +40 -0
- package/types/renderer/RendererEvents.d.ts +230 -0
- package/types/res/images.d.ts +3 -0
- package/types/scene/Axes.d.ts +11 -0
- package/types/scene/BaseNode.d.ts +60 -0
- package/types/scene/Planet.d.ts +572 -0
- package/types/scene/RenderNode.d.ts +143 -0
- package/types/scene/SkyBox.d.ts +10 -0
- package/types/scene/index.d.ts +4 -0
- package/types/segment/segmentHelper.d.ts +13 -0
- package/types/shaders/billboard.d.ts +3 -0
- package/types/shaders/depth.d.ts +2 -0
- package/types/shaders/drawnode.d.ts +7 -0
- package/types/shaders/label.d.ts +4 -0
- package/types/shaders/pointCloud.d.ts +2 -0
- package/types/shaders/polyline.d.ts +3 -0
- package/types/shaders/ray.d.ts +2 -0
- package/types/shaders/screenFrame.d.ts +2 -0
- package/types/shaders/shape.d.ts +4 -0
- package/types/shaders/skybox.d.ts +2 -0
- package/types/shaders/toneMapping.d.ts +2 -0
- package/types/shapes/BaseShape.d.ts +247 -0
- package/types/shapes/Sphere.d.ts +41 -0
- package/types/terrain/BilTerrain.d.ts +8 -0
- package/types/terrain/EmptyTerrain.d.ts +72 -0
- package/types/terrain/Geoid.d.ts +26 -0
- package/types/terrain/GlobusTerrain.d.ts +153 -0
- package/types/terrain/MapboxTerrain.d.ts +8 -0
- package/types/terrain/index.d.ts +5 -0
- package/types/utils/FontAtlas.d.ts +14 -0
- package/types/utils/GeoImageCreator.d.ts +29 -0
- package/types/utils/ImagesCacheManager.d.ts +10 -0
- package/types/utils/Loader.d.ts +25 -0
- package/types/utils/NormalMapCreator.d.ts +39 -0
- package/types/utils/PlainSegmentWorker.d.ts +10 -0
- package/types/utils/TerrainWorker.d.ts +9 -0
- package/types/utils/TextureAtlas.d.ts +111 -0
- package/types/utils/VectorTileCreator.d.ts +16 -0
- package/types/utils/colorTable.d.ts +143 -0
- package/types/utils/earcut.d.ts +6 -0
- package/types/utils/shared.d.ts +230 -0
- package/types/webgl/Framebuffer.d.ts +135 -0
- package/types/webgl/Handler.d.ts +372 -0
- package/types/webgl/Multisample.d.ts +89 -0
- package/types/webgl/Program.d.ts +155 -0
- package/types/webgl/ProgramController.d.ts +84 -0
- package/types/webgl/callbacks.d.ts +1 -0
- package/types/webgl/index.d.ts +6 -0
- package/types/webgl/types.d.ts +2 -0
package/src/og/Globe.js
CHANGED
|
@@ -13,6 +13,7 @@ import { isEmpty } from "./utils/shared.js";
|
|
|
13
13
|
|
|
14
14
|
import { EarthCoordinates } from "./control/EarthCoordinates.js";
|
|
15
15
|
import { MouseNavigation } from "./control/MouseNavigation.js";
|
|
16
|
+
import { EarthNavigation } from "./control/EarthNavigation.js";
|
|
16
17
|
import { TouchNavigation } from "./control/TouchNavigation.js";
|
|
17
18
|
import { Sun } from "./control/Sun.js";
|
|
18
19
|
import { ZoomControl } from "./control/ZoomControl.js";
|
|
@@ -81,7 +82,8 @@ class Globe {
|
|
|
81
82
|
* @public
|
|
82
83
|
* @type {Element}
|
|
83
84
|
*/
|
|
84
|
-
this.div =
|
|
85
|
+
this.div =
|
|
86
|
+
document.getElementById(options.target) || document.querySelector(options.target);
|
|
85
87
|
this.div.appendChild(this._canvas);
|
|
86
88
|
this.div.classList.add("ogViewport");
|
|
87
89
|
|
|
@@ -151,7 +153,9 @@ class Globe {
|
|
|
151
153
|
ellipsoid: options.ellipsoid,
|
|
152
154
|
maxGridSize: options.maxGridSize,
|
|
153
155
|
useNightTexture: options.useNightTexture,
|
|
154
|
-
useSpecularTexture: options.useSpecularTexture
|
|
156
|
+
useSpecularTexture: options.useSpecularTexture,
|
|
157
|
+
minAltitude: options.minAltitude,
|
|
158
|
+
maxAltitude: options.maxAltitude
|
|
155
159
|
});
|
|
156
160
|
}
|
|
157
161
|
|
|
@@ -170,7 +174,11 @@ class Globe {
|
|
|
170
174
|
} else {
|
|
171
175
|
this.planet.addControls([
|
|
172
176
|
new ZoomControl(),
|
|
173
|
-
|
|
177
|
+
options.useEarthNavigation
|
|
178
|
+
? new EarthNavigation()
|
|
179
|
+
: new MouseNavigation({
|
|
180
|
+
minSlope: options.minSlope
|
|
181
|
+
}),
|
|
174
182
|
new TouchNavigation(),
|
|
175
183
|
new EarthCoordinates(),
|
|
176
184
|
new ScaleControl(),
|
package/src/og/LonLat.js
CHANGED
|
@@ -19,166 +19,172 @@ const INV_PI_BY_180_HALF_PI = INV_PI_BY_180 * HALF_PI;
|
|
|
19
19
|
* @param {number} [lat] - Latitude.
|
|
20
20
|
* @param {number} [height] - Height over the surface.
|
|
21
21
|
*/
|
|
22
|
-
|
|
22
|
+
export class LonLat {
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
26
|
-
* @
|
|
27
|
-
* @
|
|
25
|
+
* @param {number} [lon]
|
|
26
|
+
* @param {number} [lat]
|
|
27
|
+
* @param {number} [height]
|
|
28
28
|
*/
|
|
29
|
-
|
|
29
|
+
constructor(lon, lat, height) {
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Longitude.
|
|
33
|
+
* @public
|
|
34
|
+
* @type {number}
|
|
35
|
+
*/
|
|
36
|
+
this.lon = lon || 0;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Latitude.
|
|
40
|
+
* @public
|
|
41
|
+
* @type {number}
|
|
42
|
+
*/
|
|
43
|
+
this.lat = lat || 0;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Height.
|
|
47
|
+
* @public
|
|
48
|
+
* @type {number}
|
|
49
|
+
*/
|
|
50
|
+
this.height = height || 0;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
isZero() {
|
|
54
|
+
return this.lon === 0.0 && this.lat === 0.0 && this.height === 0.0;
|
|
55
|
+
};
|
|
30
56
|
|
|
31
57
|
/**
|
|
32
|
-
*
|
|
33
|
-
* @
|
|
34
|
-
* @
|
|
58
|
+
* Creates coordinates array.
|
|
59
|
+
* @static
|
|
60
|
+
* @param{Array.<Array<number>>} arr - Coordinates array data. (exactly 3 entries)
|
|
61
|
+
* @return{Array.<og.LonLat>} the same coordinates array but each element is LonLat instance.
|
|
35
62
|
*/
|
|
36
|
-
|
|
63
|
+
static join(arr) {
|
|
64
|
+
var res = [];
|
|
65
|
+
for (var i = 0; i < arr.length; i++) {
|
|
66
|
+
var ai = arr[i];
|
|
67
|
+
res[i] = new LonLat(ai[0], ai[1], ai[2]);
|
|
68
|
+
}
|
|
69
|
+
return res;
|
|
70
|
+
};
|
|
37
71
|
|
|
38
72
|
/**
|
|
39
|
-
*
|
|
40
|
-
* @
|
|
41
|
-
* @
|
|
73
|
+
* Creates an object by coordinate array.
|
|
74
|
+
* @static
|
|
75
|
+
* @param {Array.<number>} arr - Coordiante array, where first is longitude, second is latitude and third is a height. (exactly 3 entries)
|
|
76
|
+
* @returns {og.LonLat} -
|
|
42
77
|
*/
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
LonLat.prototype.isZero = function () {
|
|
47
|
-
return this.lon === 0.0 && this.lat === 0.0 && this.height === 0.0;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Creates coordinates array.
|
|
52
|
-
* @static
|
|
53
|
-
* @param{Array.<Array<number,number,number>>} arr - Coordinates array data.
|
|
54
|
-
* @return{Array.<og.LonLat>} the same coordinates array but each element is LonLat instance.
|
|
55
|
-
*/
|
|
56
|
-
LonLat.join = function (arr) {
|
|
57
|
-
var res = [];
|
|
58
|
-
for (var i = 0; i < arr.length; i++) {
|
|
59
|
-
var ai = arr[i];
|
|
60
|
-
res[i] = new LonLat(ai[0], ai[1], ai[2]);
|
|
61
|
-
}
|
|
62
|
-
return res;
|
|
63
|
-
};
|
|
78
|
+
static createFromArray(arr) {
|
|
79
|
+
return new LonLat(arr[0], arr[1], arr[2]);
|
|
80
|
+
};
|
|
64
81
|
|
|
65
|
-
/**
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
* @param {number} lon - Degrees longitude.
|
|
79
|
-
* @param {number} lat - Degrees latitude.
|
|
80
|
-
* @param {number} [height] - Height.
|
|
81
|
-
* @returns {og.LonLat} -
|
|
82
|
-
*/
|
|
83
|
-
LonLat.forwardMercator = function (lon, lat, height) {
|
|
84
|
-
return new LonLat(lon * mercator.POLE_BY_180,
|
|
85
|
-
Math.log(Math.tan((90.0 + lat) * PI_BY_360)) * mercator.POLE_BY_PI,
|
|
86
|
-
height);
|
|
87
|
-
};
|
|
82
|
+
/**
|
|
83
|
+
* Converts degrees to mercator coordinates.
|
|
84
|
+
* @static
|
|
85
|
+
* @param {number} lon - Degrees longitude.
|
|
86
|
+
* @param {number} lat - Degrees latitude.
|
|
87
|
+
* @param {number} [height] - Height.
|
|
88
|
+
* @returns {og.LonLat} -
|
|
89
|
+
*/
|
|
90
|
+
static forwardMercator(lon, lat, height) {
|
|
91
|
+
return new LonLat(lon * mercator.POLE_BY_180,
|
|
92
|
+
Math.log(Math.tan((90.0 + lat) * PI_BY_360)) * mercator.POLE_BY_PI,
|
|
93
|
+
height);
|
|
94
|
+
};
|
|
88
95
|
|
|
89
|
-
/**
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
};
|
|
96
|
+
/**
|
|
97
|
+
* Converts mercator to degrees coordinates.
|
|
98
|
+
* @static
|
|
99
|
+
* @param {number} x - Mercator longitude.
|
|
100
|
+
* @param {number} y - Mercator latitude.
|
|
101
|
+
* @param {number} [height] - Height.
|
|
102
|
+
* @returns {og.LonLat} -
|
|
103
|
+
*/
|
|
104
|
+
static inverseMercator(x, y, height) {
|
|
105
|
+
return new LonLat(x * mercator.INV_POLE_BY_180,
|
|
106
|
+
INV_PI_BY_360 * Math.atan(Math.exp(y * mercator.PI_BY_POLE)) - INV_PI_BY_180_HALF_PI,
|
|
107
|
+
height);
|
|
108
|
+
};
|
|
102
109
|
|
|
103
|
-
/**
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
};
|
|
110
|
+
/**
|
|
111
|
+
* Sets coordinates.
|
|
112
|
+
* @public
|
|
113
|
+
* @param {number} [lon] - Longitude.
|
|
114
|
+
* @param {number} [lat] - Latitude.
|
|
115
|
+
* @param {number} [height] - Height.
|
|
116
|
+
* @returns {og.LonLat} -
|
|
117
|
+
*/
|
|
118
|
+
set(lon, lat, height) {
|
|
119
|
+
this.lon = lon || 0;
|
|
120
|
+
this.lat = lat || 0;
|
|
121
|
+
this.height = height || 0;
|
|
122
|
+
return this;
|
|
123
|
+
};
|
|
117
124
|
|
|
118
|
-
/**
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
};
|
|
125
|
+
/**
|
|
126
|
+
* Copy coordinates.
|
|
127
|
+
* @public
|
|
128
|
+
* @param {og.LonLat} [lonLat] - Coordinates to copy.
|
|
129
|
+
* @returns {og.LonLat} -
|
|
130
|
+
*/
|
|
131
|
+
copy(lonLat) {
|
|
132
|
+
this.lon = lonLat.lon;
|
|
133
|
+
this.lat = lonLat.lat;
|
|
134
|
+
this.height = lonLat.height;
|
|
135
|
+
return this;
|
|
136
|
+
};
|
|
130
137
|
|
|
131
|
-
/**
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
};
|
|
138
|
+
/**
|
|
139
|
+
* Clone the coordiante.
|
|
140
|
+
* @public
|
|
141
|
+
* @returns {og.LonLat} -
|
|
142
|
+
*/
|
|
143
|
+
clone() {
|
|
144
|
+
return new LonLat(this.lon, this.lat, this.height);
|
|
145
|
+
};
|
|
139
146
|
|
|
140
|
-
/**
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
};
|
|
147
|
+
/**
|
|
148
|
+
* Converts to mercator coordinates.
|
|
149
|
+
* @public
|
|
150
|
+
* @returns {og.LonLat} -
|
|
151
|
+
*/
|
|
152
|
+
forwardMercator() {
|
|
153
|
+
return LonLat.forwardMercator(this.lon, this.lat, this.height);
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
forwardMercatorEPS01() {
|
|
157
|
+
var lat = this.lat;
|
|
158
|
+
if (lat > 89.9) {
|
|
159
|
+
lat = 89.9;
|
|
160
|
+
} else if (lat < -89.9) {
|
|
161
|
+
lat = -89.9;
|
|
162
|
+
}
|
|
163
|
+
return new LonLat(
|
|
164
|
+
this.lon * mercator.POLE_BY_180,
|
|
165
|
+
Math.log(Math.tan((90.0 + lat) * PI_BY_360)) * mercator.POLE_BY_PI);
|
|
166
|
+
};
|
|
160
167
|
|
|
161
|
-
/**
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
};
|
|
168
|
+
/**
|
|
169
|
+
* Converts from mercator coordinates.
|
|
170
|
+
* @public
|
|
171
|
+
* @returns {og.LonLat} -
|
|
172
|
+
*/
|
|
173
|
+
inverseMercator() {
|
|
174
|
+
return LonLat.inverseMercator(this.lon, this.lat, this.height);
|
|
175
|
+
};
|
|
169
176
|
|
|
170
|
-
/**
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
export { LonLat };
|
|
177
|
+
/**
|
|
178
|
+
* Compares coordinates.
|
|
179
|
+
* @public
|
|
180
|
+
* @param {og.LonLat} b - Coordinate to compare with.
|
|
181
|
+
* @returns {boolean} -
|
|
182
|
+
*/
|
|
183
|
+
equal(b) {
|
|
184
|
+
if (b.height) {
|
|
185
|
+
return this.lon === b.lon && this.lat === b.lat && this.height === b.height;
|
|
186
|
+
} else {
|
|
187
|
+
return this.lon === b.lon && this.lat === b.lat;
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
}
|
package/src/og/Popup.js
CHANGED
|
@@ -72,7 +72,7 @@ class Popup {
|
|
|
72
72
|
|
|
73
73
|
setScreen(p) {
|
|
74
74
|
if (this._planet) {
|
|
75
|
-
this.el.style.transform = "translate(" + (p.x - this.clientWidth * 0.5) + "px, " + (p.y - this._planet.renderer.handler.canvas.height - this.clientHeight
|
|
75
|
+
this.el.style.transform = "translate(" + (p.x - this.clientWidth * 0.5) + "px, " + (p.y - this._planet.renderer.handler.canvas.height - this._tipEl.clientHeight) + "px)"
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
|
|
@@ -98,6 +98,7 @@ class Popup {
|
|
|
98
98
|
this.el = this._renderTemplate(params);
|
|
99
99
|
this._contentEl = this.el.querySelector(".og-popup-content");
|
|
100
100
|
this._titleEl = this.el.querySelector(".og-popup-title")
|
|
101
|
+
this._tipEl = this.el.querySelector(".og-popup-tip-container")
|
|
101
102
|
this.setOffset(this._offset[0], this._offset[1]);
|
|
102
103
|
this.setContent(this._content);
|
|
103
104
|
this.setTitle(this._title);
|
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
* @module og/camera/PlanetCamera
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import * as math from
|
|
8
|
-
import * as mercator from
|
|
9
|
-
import { Camera } from
|
|
10
|
-
import { Vec3 } from
|
|
11
|
-
import { Key } from
|
|
12
|
-
import { LonLat } from
|
|
13
|
-
import { Ray } from
|
|
14
|
-
import { Quat } from
|
|
15
|
-
import { Mat4 } from
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
import * as math from "../math.js";
|
|
8
|
+
import * as mercator from "../mercator.js";
|
|
9
|
+
import { Camera } from "./Camera.js";
|
|
10
|
+
import { Vec3 } from "../math/Vec3.js";
|
|
11
|
+
import { Key } from "../Lock.js";
|
|
12
|
+
import { LonLat } from "../LonLat.js";
|
|
13
|
+
import { Ray } from "../math/Ray.js";
|
|
14
|
+
import { Quat } from "../math/Quat.js";
|
|
15
|
+
import { Mat4 } from "../math/Mat4.js";
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Planet camera.
|
|
@@ -24,17 +24,28 @@ import { Mat4 } from '../math/Mat4.js';
|
|
|
24
24
|
* @param {number} [options.viewAngle=37] - Camera angle of view. Default is 35.0
|
|
25
25
|
* @param {number} [options.near] - Camera near plane distance. Default is 1.0
|
|
26
26
|
* @param {number} [options.far] - Camera far plane distance. Deafult is og.math.MAX
|
|
27
|
-
* @param {number} [options.minAltitude] - Minimal altitude for the camera. Deafult is
|
|
27
|
+
* @param {number} [options.minAltitude] - Minimal altitude for the camera. Deafult is 1
|
|
28
|
+
* @param {number} [options.maxAltitude] - Maximal altitude for the camera. Deafult is 20000000
|
|
28
29
|
* @param {og.Vec3} [options.eye] - Camera eye position. Default (0,0,0)
|
|
29
30
|
* @param {og.Vec3} [options.look] - Camera look position. Default (0,0,0)
|
|
30
31
|
* @param {og.Vec3} [options.up] - Camera eye position. Default (0,1,0)
|
|
31
32
|
*/
|
|
32
33
|
class PlanetCamera extends Camera {
|
|
33
34
|
constructor(planet, options) {
|
|
34
|
-
super(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
super(
|
|
36
|
+
planet.renderer,
|
|
37
|
+
Object.assign(
|
|
38
|
+
{},
|
|
39
|
+
{
|
|
40
|
+
frustums: /*[[100, 10000000]]*/ [
|
|
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
|
+
},
|
|
47
|
+
options
|
|
48
|
+
)
|
|
38
49
|
);
|
|
39
50
|
/**
|
|
40
51
|
* Assigned camera's planet.
|
|
@@ -50,6 +61,13 @@ class PlanetCamera extends Camera {
|
|
|
50
61
|
*/
|
|
51
62
|
this.minAltitude = options.minAltitude || 1;
|
|
52
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Maximal alltitude that camera can reach over the globe.
|
|
66
|
+
* @public
|
|
67
|
+
* @type {number}
|
|
68
|
+
*/
|
|
69
|
+
this.maxAltitude = options.maxAltitude || 20000000;
|
|
70
|
+
|
|
53
71
|
/**
|
|
54
72
|
* Current geographical degree position.
|
|
55
73
|
* @protected
|
|
@@ -112,6 +130,13 @@ class PlanetCamera extends Camera {
|
|
|
112
130
|
*/
|
|
113
131
|
update() {
|
|
114
132
|
this.events.stopPropagation();
|
|
133
|
+
|
|
134
|
+
let maxAlt = this.maxAltitude + this.planet.ellipsoid._a;
|
|
135
|
+
|
|
136
|
+
if (this.eye.length() > maxAlt) {
|
|
137
|
+
this.eye.copy(this.eye.normal().scale(maxAlt));
|
|
138
|
+
}
|
|
139
|
+
|
|
115
140
|
super.update();
|
|
116
141
|
this.updateGeodeticPosition();
|
|
117
142
|
this.eyeNorm = this.eye.normal();
|
|
@@ -191,7 +216,6 @@ class PlanetCamera extends Camera {
|
|
|
191
216
|
* @returns {og.Vec3}
|
|
192
217
|
*/
|
|
193
218
|
getExtentPosition(extent, height) {
|
|
194
|
-
|
|
195
219
|
var north = extent.getNorth();
|
|
196
220
|
var south = extent.getSouth();
|
|
197
221
|
var east = extent.getEast();
|
|
@@ -273,10 +297,18 @@ class PlanetCamera extends Camera {
|
|
|
273
297
|
* @param {Number} [ampl] - Altitude amplitude factor.
|
|
274
298
|
* @param {cameraCallback} [completeCallback] - Callback that calls after flying when flying is finished.
|
|
275
299
|
* @param {cameraCallback} [startCallback] - Callback that calls befor the flying begins.
|
|
300
|
+
* @param [frameCallback]
|
|
276
301
|
*/
|
|
277
302
|
flyExtent(extent, height, up, ampl, completeCallback, startCallback, frameCallback) {
|
|
278
|
-
this.flyCartesian(
|
|
279
|
-
|
|
303
|
+
this.flyCartesian(
|
|
304
|
+
this.getExtentPosition(extent, height),
|
|
305
|
+
Vec3.ZERO,
|
|
306
|
+
up,
|
|
307
|
+
ampl,
|
|
308
|
+
completeCallback,
|
|
309
|
+
startCallback,
|
|
310
|
+
frameCallback
|
|
311
|
+
);
|
|
280
312
|
}
|
|
281
313
|
|
|
282
314
|
viewDistance(cartesian, distance = 10000.0) {
|
|
@@ -293,7 +325,14 @@ class PlanetCamera extends Camera {
|
|
|
293
325
|
this.update();
|
|
294
326
|
}
|
|
295
327
|
|
|
296
|
-
flyDistance(
|
|
328
|
+
flyDistance(
|
|
329
|
+
cartesian,
|
|
330
|
+
distance = 10000.0,
|
|
331
|
+
ampl = 0.0,
|
|
332
|
+
completeCallback,
|
|
333
|
+
startCallback,
|
|
334
|
+
frameCallback
|
|
335
|
+
) {
|
|
297
336
|
let p0 = this.eye.add(this.getForward().scaleTo(distance));
|
|
298
337
|
let _rot = Quat.getRotationBetweenVectors(p0.normal(), cartesian.normal());
|
|
299
338
|
if (_rot.isZero()) {
|
|
@@ -302,7 +341,15 @@ class PlanetCamera extends Camera {
|
|
|
302
341
|
} else {
|
|
303
342
|
let newPos = cartesian.add(_rot.mulVec3(this.getBackward()).scale(distance)),
|
|
304
343
|
newUp = _rot.mulVec3(this.getUp());
|
|
305
|
-
this.flyCartesian(
|
|
344
|
+
this.flyCartesian(
|
|
345
|
+
newPos,
|
|
346
|
+
cartesian,
|
|
347
|
+
newUp,
|
|
348
|
+
ampl,
|
|
349
|
+
completeCallback,
|
|
350
|
+
startCallback,
|
|
351
|
+
frameCallback
|
|
352
|
+
);
|
|
306
353
|
}
|
|
307
354
|
}
|
|
308
355
|
|
|
@@ -315,9 +362,9 @@ class PlanetCamera extends Camera {
|
|
|
315
362
|
* @param {Number} [ampl=1.0] - Altitude amplitude factor.
|
|
316
363
|
* @param {cameraCallback} [completeCallback] - Callback that calls after flying when flying is finished.
|
|
317
364
|
* @param {cameraCallback} [startCallback] - Callback that calls befor the flying begins.
|
|
365
|
+
* @param [frameCallback]
|
|
318
366
|
*/
|
|
319
367
|
flyCartesian(cartesian, look, up, ampl = 1.0, completeCallback, startCallback, frameCallback) {
|
|
320
|
-
|
|
321
368
|
this.stopFlying();
|
|
322
369
|
|
|
323
370
|
this._completeCallback = completeCallback;
|
|
@@ -333,13 +380,17 @@ class PlanetCamera extends Camera {
|
|
|
333
380
|
look = this.planet.ellipsoid.lonLatToCartesian(look);
|
|
334
381
|
}
|
|
335
382
|
|
|
336
|
-
var ground_a = this.planet.ellipsoid.lonLatToCartesian(
|
|
383
|
+
var ground_a = this.planet.ellipsoid.lonLatToCartesian(
|
|
384
|
+
new LonLat(this._lonLat.lon, this._lonLat.lat)
|
|
385
|
+
);
|
|
337
386
|
var v_a = this._v,
|
|
338
387
|
n_a = this._n;
|
|
339
388
|
|
|
340
389
|
var lonlat_b = this.planet.ellipsoid.cartesianToLonLat(cartesian);
|
|
341
390
|
var up_b = up || Vec3.UP;
|
|
342
|
-
var ground_b = this.planet.ellipsoid.lonLatToCartesian(
|
|
391
|
+
var ground_b = this.planet.ellipsoid.lonLatToCartesian(
|
|
392
|
+
new LonLat(lonlat_b.lon, lonlat_b.lat, 0)
|
|
393
|
+
);
|
|
343
394
|
var eye_b = cartesian;
|
|
344
395
|
var n_b = Vec3.sub(eye_b, look);
|
|
345
396
|
var u_b = up_b.cross(n_b);
|
|
@@ -350,7 +401,7 @@ class PlanetCamera extends Camera {
|
|
|
350
401
|
var an = ground_a.normal();
|
|
351
402
|
var bn = ground_b.normal();
|
|
352
403
|
var anbn = 1.0 - an.dot(bn);
|
|
353
|
-
var hM_a = ampl * math.SQRT_HALF * Math.sqrt(
|
|
404
|
+
var hM_a = ampl * math.SQRT_HALF * Math.sqrt(anbn > 0.0 ? anbn : 0.0);
|
|
354
405
|
|
|
355
406
|
var maxHeight = 6639613;
|
|
356
407
|
var currMaxHeight = Math.max(this._lonLat.height, lonlat_b.height);
|
|
@@ -370,7 +421,11 @@ class PlanetCamera extends Camera {
|
|
|
370
421
|
var g_i = ground_a.smerp(ground_b, d).normalize();
|
|
371
422
|
var ground_i = this.planet.getRayIntersectionEllipsoid(new Ray(zero, g_i));
|
|
372
423
|
var t = 1 - d;
|
|
373
|
-
var height_i =
|
|
424
|
+
var height_i =
|
|
425
|
+
this._lonLat.height * d * d * d +
|
|
426
|
+
max_h * 3 * d * d * t +
|
|
427
|
+
max_h * 3 * d * t * t +
|
|
428
|
+
lonlat_b.height * t * t * t;
|
|
374
429
|
|
|
375
430
|
var eye_i = ground_i.addA(g_i.scale(height_i));
|
|
376
431
|
var up_i = v_a.smerp(v_b, d);
|
|
@@ -406,7 +461,14 @@ class PlanetCamera extends Camera {
|
|
|
406
461
|
*/
|
|
407
462
|
flyLonLat(lonlat, look, up, ampl, completeCallback, startCallback) {
|
|
408
463
|
var _lonlat = new LonLat(lonlat.lon, lonlat.lat, lonlat.height || this._lonLat.height);
|
|
409
|
-
this.flyCartesian(
|
|
464
|
+
this.flyCartesian(
|
|
465
|
+
this.planet.ellipsoid.lonLatToCartesian(_lonlat),
|
|
466
|
+
look,
|
|
467
|
+
up,
|
|
468
|
+
ampl,
|
|
469
|
+
completeCallback,
|
|
470
|
+
startCallback
|
|
471
|
+
);
|
|
410
472
|
}
|
|
411
473
|
|
|
412
474
|
/**
|
|
@@ -414,7 +476,6 @@ class PlanetCamera extends Camera {
|
|
|
414
476
|
* @public
|
|
415
477
|
*/
|
|
416
478
|
stopFlying() {
|
|
417
|
-
|
|
418
479
|
this.planet.layerLock.free(this._keyLock);
|
|
419
480
|
this.planet.terrainLock.free(this._keyLock);
|
|
420
481
|
this.planet._normalMapCreator.free(this._keyLock);
|
|
@@ -477,7 +538,7 @@ class PlanetCamera extends Camera {
|
|
|
477
538
|
this.update();
|
|
478
539
|
}
|
|
479
540
|
|
|
480
|
-
rotateVertical(angle, center,
|
|
541
|
+
rotateVertical(angle, center, minSlope = 0) {
|
|
481
542
|
var rot = new Mat4().setRotation(this._u, angle);
|
|
482
543
|
var tr = new Mat4().setIdentity().translate(center);
|
|
483
544
|
var ntr = new Mat4().setIdentity().translate(center.negateTo());
|
|
@@ -491,9 +552,16 @@ class PlanetCamera extends Camera {
|
|
|
491
552
|
let eyeNorm = eye.normal();
|
|
492
553
|
let slope = n.dot(eyeNorm);
|
|
493
554
|
|
|
494
|
-
if (
|
|
495
|
-
|
|
496
|
-
|
|
555
|
+
if (minSlope) {
|
|
556
|
+
let dSlope = slope - this.slope;
|
|
557
|
+
|
|
558
|
+
if (slope < minSlope && dSlope < 0) return;
|
|
559
|
+
|
|
560
|
+
if (
|
|
561
|
+
(slope > 0.1 && v.dot(eyeNorm) > 0) ||
|
|
562
|
+
this.slope <= 0.1 ||
|
|
563
|
+
this._v.dot(this.eye.normal()) <= 0.0
|
|
564
|
+
) {
|
|
497
565
|
this.eye = eye;
|
|
498
566
|
this._v = v;
|
|
499
567
|
this._u = u;
|
|
@@ -544,8 +612,12 @@ class PlanetCamera extends Camera {
|
|
|
544
612
|
|
|
545
613
|
checkTerrainCollision() {
|
|
546
614
|
this._terrainAltitude = this._lonLat.height;
|
|
547
|
-
if (this.
|
|
548
|
-
this._terrainAltitude = this._insideSegment.getTerrainPoint(
|
|
615
|
+
if (this._insideSegment && this._insideSegment.planet) {
|
|
616
|
+
this._terrainAltitude = this._insideSegment.getTerrainPoint(
|
|
617
|
+
this.eye,
|
|
618
|
+
this._insideSegmentPosition,
|
|
619
|
+
this._terrainPoint
|
|
620
|
+
);
|
|
549
621
|
if (this._terrainAltitude < this.minAltitude) {
|
|
550
622
|
this.setAltitude(this.minAltitude);
|
|
551
623
|
}
|
|
@@ -559,7 +631,10 @@ class PlanetCamera extends Camera {
|
|
|
559
631
|
|
|
560
632
|
getHeading() {
|
|
561
633
|
let u = this.eye.normal();
|
|
562
|
-
let f = Vec3.proj_b_to_plane(
|
|
634
|
+
let f = Vec3.proj_b_to_plane(
|
|
635
|
+
this.slope >= 0.97 ? this.getUp() : this.getForward(),
|
|
636
|
+
u
|
|
637
|
+
).normalize(),
|
|
563
638
|
n = Vec3.proj_b_to_plane(Vec3.UP, u).normalize();
|
|
564
639
|
let res = Math.sign(u.dot(f.cross(n))) * Math.acos(f.dot(n)) * math.DEGREES;
|
|
565
640
|
if (res < 0.0) {
|
|
@@ -567,7 +642,6 @@ class PlanetCamera extends Camera {
|
|
|
567
642
|
}
|
|
568
643
|
return res;
|
|
569
644
|
}
|
|
645
|
+
}
|
|
570
646
|
|
|
571
|
-
};
|
|
572
|
-
|
|
573
|
-
export { PlanetCamera };
|
|
647
|
+
export { PlanetCamera };
|