@openglobus/og 0.14.10 → 0.15.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 +378 -275
- package/dist/@openglobus/og.css +1 -1
- package/dist/@openglobus/og.esm.js +2 -2
- package/dist/@openglobus/og.esm.js.map +1 -1
- package/dist/@openglobus/og.umd.js +2 -2
- package/dist/@openglobus/og.umd.js.map +1 -1
- package/package.json +18 -17
- package/src/og/Clock.js +218 -194
- package/src/og/Globe.js +5 -5
- package/src/og/Object3d.js +104 -145
- package/src/og/camera/Camera.js +31 -27
- package/src/og/camera/PlanetCamera.js +22 -14
- package/src/og/cons.js +107 -107
- package/src/og/control/Atmosphere.js +396 -0
- package/src/og/control/CompassButton.js +11 -18
- package/src/og/control/Control.js +197 -188
- package/src/og/control/GeoImageDragControl.js +84 -66
- package/src/og/control/LayerSwitcher.js +56 -138
- package/src/og/control/Lighting.js +314 -186
- package/src/og/control/MouseNavigation.js +2 -2
- package/src/og/control/RulerSwitcher.js +24 -19
- package/src/og/control/ScaleControl.js +30 -10
- package/src/og/control/SimpleSkyBackground.js +210 -0
- package/src/og/control/Sun.js +3 -1
- package/src/og/control/ZoomControl.js +30 -42
- package/src/og/control/index.js +6 -0
- package/src/og/control/ruler/RulerScene.js +5 -23
- package/src/og/control/selection/Selection.js +99 -0
- package/src/og/control/selection/SelectionScene.js +350 -0
- package/src/og/control/timeline/TimelineControl.js +99 -0
- package/src/og/control/timeline/TimelineModel.js +133 -0
- package/src/og/control/timeline/TimelineView.js +449 -0
- package/src/og/control/timeline/timelineUtils.js +132 -0
- package/src/og/ellipsoid/Ellipsoid.js +120 -93
- package/src/og/ellipsoid/wgs84.js +13 -13
- package/src/og/entity/Entity.js +36 -9
- package/src/og/entity/EntityCollection.js +0 -2
- package/src/og/entity/GeoObject.js +72 -56
- package/src/og/entity/GeoObjectHandler.js +487 -656
- package/src/og/entity/GeometryHandler.js +1341 -1337
- package/src/og/entity/Polyline.js +0 -16
- package/src/og/entity/Ray.js +0 -10
- package/src/og/entity/RayHandler.js +3 -44
- package/src/og/entity/Strip.js +1 -6
- package/src/og/index.js +13 -7
- package/src/og/input/input.js +3 -1
- package/src/og/layer/CanvasTiles.js +39 -34
- package/src/og/layer/Layer.js +69 -9
- package/src/og/layer/Material.js +1 -8
- package/src/og/layer/WMS.js +16 -5
- package/src/og/light/LightSource.js +2 -0
- package/src/og/math/Line3.js +140 -139
- package/src/og/math/Plane.js +118 -117
- package/src/og/math/Ray.js +242 -239
- package/src/og/math/Vec3.js +56 -37
- package/src/og/math/Vec4.js +3 -4
- package/src/og/math.js +21 -21
- package/src/og/quadTree/Node.js +5 -4
- package/src/og/quadTree/index.js +12 -0
- package/src/og/renderer/Renderer.js +64 -37
- package/src/og/renderer/RendererEvents.js +1071 -1065
- package/src/og/scene/Planet.js +354 -174
- package/src/og/scene/RenderNode.js +27 -12
- package/src/og/segment/Segment.js +0 -5
- package/src/og/shaders/atmos.js +332 -0
- package/src/og/shaders/drawnode.js +475 -109
- package/src/og/shaders/geoObject.js +96 -51
- package/src/og/shaders/polyline.js +212 -17
- package/src/og/shaders/ray.js +13 -6
- package/src/og/shaders/toneMapping.js +5 -5
- package/src/og/shaders/utils.js +88 -0
- package/src/og/terrain/GlobusTerrain.js +5 -4
- package/src/og/terrain/MapboxTerrain.js +231 -52
- package/src/og/ui/Button.js +106 -0
- package/src/og/ui/ButtonGroup.js +57 -0
- package/src/og/ui/Dialog.js +242 -0
- package/src/og/ui/Slider.js +144 -0
- package/src/og/ui/ToggleButton.js +51 -0
- package/src/og/{control → ui}/UIhelpers.js +11 -2
- package/src/og/ui/View.js +190 -0
- package/src/og/utils/shared.js +960 -942
- package/src/og/webgl/Framebuffer.js +308 -387
- package/src/og/webgl/Handler.js +90 -30
- package/src/og/webgl/Multisample.js +8 -0
- package/types/Clock.d.ts +7 -2
- package/types/Object3d.d.ts +14 -3
- package/types/camera/Camera.d.ts +18 -17
- package/types/camera/PlanetCamera.d.ts +3 -1
- package/types/control/Atmosphere.d.ts +15 -0
- package/types/control/CompassButton.d.ts +1 -2
- package/types/control/GeoImageDragControl.d.ts +7 -1
- package/types/control/LayerSwitcher.d.ts +5 -6
- package/types/control/Lighting.d.ts +32 -7
- package/types/control/ScaleControl.d.ts +2 -1
- package/types/control/SimpleSkyBackground.d.ts +15 -0
- package/types/control/ZoomControl.d.ts +0 -1
- package/types/control/index.d.ts +4 -1
- package/types/control/ruler/RulerScene.d.ts +0 -1
- package/types/control/selection/Selection.d.ts +49 -0
- package/types/control/selection/SelectionScene.d.ts +34 -0
- package/types/ellipsoid/Ellipsoid.d.ts +3 -2
- package/types/entity/Entity.d.ts +8 -0
- package/types/entity/GeoObject.d.ts +28 -22
- package/types/entity/GeoObjectHandler.d.ts +16 -56
- package/types/entity/Ray.d.ts +0 -3
- package/types/entity/RayHandler.d.ts +0 -4
- package/types/index.d.ts +9 -6
- package/types/input/input.d.ts +2 -0
- package/types/layer/CanvasTiles.d.ts +1 -0
- package/types/layer/Layer.d.ts +9 -0
- package/types/layer/WMS.d.ts +7 -3
- package/types/math/Plane.d.ts +1 -1
- package/types/math/Vec3.d.ts +19 -16
- package/types/math/Vec4.d.ts +2 -3
- package/types/math.d.ts +20 -20
- package/types/quadTree/index.d.ts +10 -0
- package/types/renderer/Renderer.d.ts +11 -37
- package/types/scene/Planet.d.ts +27 -1
- package/types/scene/RenderNode.d.ts +2 -1
- package/types/segment/Segment.d.ts +1 -1
- package/types/shaders/atmos.d.ts +4 -0
- package/types/shaders/drawnode.d.ts +3 -2
- package/types/shaders/utils.d.ts +1 -0
- package/types/terrain/GlobusTerrain.d.ts +1 -1
- package/types/terrain/MapboxTerrain.d.ts +2 -1
- package/types/ui/Button.d.ts +21 -0
- package/types/ui/Dialog.d.ts +41 -0
- package/types/ui/Slider.d.ts +30 -0
- package/types/ui/ToggleButton.d.ts +10 -0
- package/types/{control → ui}/UIhelpers.d.ts +1 -1
- package/types/ui/View.d.ts +32 -0
- package/types/utils/shared.d.ts +16 -14
- package/types/webgl/Framebuffer.d.ts +2 -5
- package/types/webgl/Handler.d.ts +15 -10
- package/types/webgl/Multisample.d.ts +2 -0
- package/src/og/ajax.js +0 -204
- package/src/og/entity/Object3d.js +0 -504
- package/src/og/utils/quadTreeType.js +0 -11
- package/types/ajax.d.ts +0 -24
- package/types/utils/quadTreeType.d.ts +0 -8
|
@@ -4,10 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
"use strict";
|
|
6
6
|
|
|
7
|
-
import * as math from "../math.js";
|
|
8
7
|
import { Vec3 } from "../math/Vec3.js";
|
|
9
8
|
import { LonLat } from "../LonLat.js";
|
|
10
|
-
import {
|
|
9
|
+
import { EPS1, EPS12, EPS15, RADIANS, DEGREES } from "../math.js";
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
12
|
* Class represents a plant ellipsoid.
|
|
@@ -65,10 +64,10 @@ class Ellipsoid {
|
|
|
65
64
|
* @returns {number} Distance in m between this point and destination point (same units as radius).
|
|
66
65
|
*/
|
|
67
66
|
rhumbDistanceTo(startLonLat, endLonLat) {
|
|
68
|
-
const f1 = startLonLat.lat *
|
|
69
|
-
const f2 = endLonLat.lat *
|
|
67
|
+
const f1 = startLonLat.lat * RADIANS;
|
|
68
|
+
const f2 = endLonLat.lat * RADIANS;
|
|
70
69
|
const df = f2 - f1;
|
|
71
|
-
let d = Math.abs(endLonLat.lon - startLonLat.lon) *
|
|
70
|
+
let d = Math.abs(endLonLat.lon - startLonLat.lon) * RADIANS;
|
|
72
71
|
if (Math.abs(d) > Math.PI) d = d > 0 ? -(2 * Math.PI - d) : (2 * Math.PI + d);
|
|
73
72
|
const dd = Math.log(Math.tan(f2 / 2 + Math.PI / 4) / Math.tan(f1 / 2 + Math.PI / 4));
|
|
74
73
|
const q = Math.abs(dd) > 10e-12 ? df / dd : Math.cos(f1);
|
|
@@ -83,10 +82,10 @@ class Ellipsoid {
|
|
|
83
82
|
* @return {LonLat} Midpoint between points.
|
|
84
83
|
*/
|
|
85
84
|
static getMiddlePointOnGreatCircle(lonLat1, lonLat2) {
|
|
86
|
-
var f1 = lonLat1.lat *
|
|
87
|
-
l1 = lonLat1.lon *
|
|
88
|
-
var f2 = lonLat2.lat *
|
|
89
|
-
var dl = (lonLat2.lon - lonLat1.lon) *
|
|
85
|
+
var f1 = lonLat1.lat * RADIANS,
|
|
86
|
+
l1 = lonLat1.lon * RADIANS;
|
|
87
|
+
var f2 = lonLat2.lat * RADIANS;
|
|
88
|
+
var dl = (lonLat2.lon - lonLat1.lon) * RADIANS;
|
|
90
89
|
|
|
91
90
|
var Bx = Math.cos(f2) * Math.cos(dl);
|
|
92
91
|
var By = Math.cos(f2) * Math.sin(dl);
|
|
@@ -97,7 +96,7 @@ class Ellipsoid {
|
|
|
97
96
|
|
|
98
97
|
var l3 = l1 + Math.atan2(By, Math.cos(f1) + Bx);
|
|
99
98
|
|
|
100
|
-
return new LonLat(((l3 *
|
|
99
|
+
return new LonLat(((l3 * DEGREES + 540) % 360) - 180, f3 * DEGREES);
|
|
101
100
|
}
|
|
102
101
|
|
|
103
102
|
/**
|
|
@@ -108,10 +107,10 @@ class Ellipsoid {
|
|
|
108
107
|
* @returns {LonLat} Intermediate point between points.
|
|
109
108
|
*/
|
|
110
109
|
static getIntermediatePointOnGreatCircle(lonLat1, lonLat2, fraction) {
|
|
111
|
-
var f1 = lonLat1.lat *
|
|
112
|
-
l1 = lonLat1.lon *
|
|
113
|
-
var f2 = lonLat2.lat *
|
|
114
|
-
l2 = lonLat2.lon *
|
|
110
|
+
var f1 = lonLat1.lat * RADIANS,
|
|
111
|
+
l1 = lonLat1.lon * RADIANS;
|
|
112
|
+
var f2 = lonLat2.lat * RADIANS,
|
|
113
|
+
l2 = lonLat2.lon * RADIANS;
|
|
115
114
|
|
|
116
115
|
var sinf1 = Math.sin(f1),
|
|
117
116
|
cosf1 = Math.cos(f1),
|
|
@@ -139,14 +138,14 @@ class Ellipsoid {
|
|
|
139
138
|
var f3 = Math.atan2(z, Math.sqrt(x * x + y * y));
|
|
140
139
|
var l3 = Math.atan2(y, x);
|
|
141
140
|
|
|
142
|
-
return new LonLat(((l3 *
|
|
141
|
+
return new LonLat(((l3 * DEGREES + 540) % 360) - 180, f3 * DEGREES);
|
|
143
142
|
}
|
|
144
143
|
|
|
145
144
|
static getRhumbBearing(lonLat1, lonLat2) {
|
|
146
|
-
var dLon = (lonLat2.lon - lonLat1.lon) *
|
|
145
|
+
var dLon = (lonLat2.lon - lonLat1.lon) * RADIANS;
|
|
147
146
|
var dPhi = Math.log(
|
|
148
|
-
Math.tan((lonLat2.lat *
|
|
149
|
-
Math.tan((lonLat1.lat *
|
|
147
|
+
Math.tan((lonLat2.lat * RADIANS) / 2 + Math.PI / 4) /
|
|
148
|
+
Math.tan((lonLat1.lat * RADIANS) / 2 + Math.PI / 4)
|
|
150
149
|
);
|
|
151
150
|
if (Math.abs(dLon) > Math.PI) {
|
|
152
151
|
if (dLon > 0) {
|
|
@@ -155,17 +154,17 @@ class Ellipsoid {
|
|
|
155
154
|
dLon = 2 * Math.PI + dLon;
|
|
156
155
|
}
|
|
157
156
|
}
|
|
158
|
-
return (Math.atan2(dLon, dPhi) *
|
|
157
|
+
return (Math.atan2(dLon, dPhi) * DEGREES + 360) % 360;
|
|
159
158
|
}
|
|
160
159
|
|
|
161
160
|
static getBearing(lonLat1, lonLat2) {
|
|
162
|
-
var f1 = lonLat1.lat *
|
|
163
|
-
l1 = lonLat1.lon *
|
|
164
|
-
var f2 = lonLat2.lat *
|
|
165
|
-
l2 = lonLat2.lon *
|
|
161
|
+
var f1 = lonLat1.lat * RADIANS,
|
|
162
|
+
l1 = lonLat1.lon * RADIANS;
|
|
163
|
+
var f2 = lonLat2.lat * RADIANS,
|
|
164
|
+
l2 = lonLat2.lon * RADIANS;
|
|
166
165
|
var y = Math.sin(l2 - l1) * Math.cos(f2);
|
|
167
166
|
var x = Math.cos(f1) * Math.sin(f2) - Math.sin(f1) * Math.cos(f2) * Math.cos(l2 - l1);
|
|
168
|
-
return Math.atan2(y, x) *
|
|
167
|
+
return Math.atan2(y, x) * DEGREES;
|
|
169
168
|
}
|
|
170
169
|
|
|
171
170
|
/**
|
|
@@ -175,13 +174,13 @@ class Ellipsoid {
|
|
|
175
174
|
* @return {number} Initial bearing in degrees from north.
|
|
176
175
|
*/
|
|
177
176
|
static getInitialBearing(lonLat1, lonLat2) {
|
|
178
|
-
var f1 = lonLat1.lat *
|
|
179
|
-
f2 = lonLat2.lat *
|
|
180
|
-
var dl = (lonLat2.lon - lonLat1.lon) *
|
|
177
|
+
var f1 = lonLat1.lat * RADIANS,
|
|
178
|
+
f2 = lonLat2.lat * RADIANS;
|
|
179
|
+
var dl = (lonLat2.lon - lonLat1.lon) * RADIANS;
|
|
181
180
|
var y = Math.sin(dl) * Math.cos(f2);
|
|
182
181
|
var x = Math.cos(f1) * Math.sin(f2) - Math.sin(f1) * Math.cos(f2) * Math.cos(dl);
|
|
183
182
|
var D = Math.atan2(y, x);
|
|
184
|
-
return (D *
|
|
183
|
+
return (D * DEGREES + 360) % 360;
|
|
185
184
|
}
|
|
186
185
|
|
|
187
186
|
/**
|
|
@@ -193,12 +192,12 @@ class Ellipsoid {
|
|
|
193
192
|
* @return {LonLat|null} Destination point (null if no unique intersection defined).
|
|
194
193
|
*/
|
|
195
194
|
static intersection(p1, brng1, p2, brng2) {
|
|
196
|
-
var f1 = p1.lat *
|
|
197
|
-
l1 = p1.lon *
|
|
198
|
-
var f2 = p2.lat *
|
|
199
|
-
l2 = p2.lon *
|
|
200
|
-
var D13 = brng1 *
|
|
201
|
-
D23 = brng2 *
|
|
195
|
+
var f1 = p1.lat * RADIANS,
|
|
196
|
+
l1 = p1.lon * RADIANS;
|
|
197
|
+
var f2 = p2.lat * RADIANS,
|
|
198
|
+
l2 = p2.lon * RADIANS;
|
|
199
|
+
var D13 = brng1 * RADIANS,
|
|
200
|
+
D23 = brng2 * RADIANS;
|
|
202
201
|
var df = f2 - f1,
|
|
203
202
|
dl = l2 - l1;
|
|
204
203
|
|
|
@@ -250,7 +249,7 @@ class Ellipsoid {
|
|
|
250
249
|
);
|
|
251
250
|
var l3 = l1 + dl13;
|
|
252
251
|
|
|
253
|
-
return new LonLat(((l3 *
|
|
252
|
+
return new LonLat(((l3 * DEGREES + 540) % 360) - 180, f3 * DEGREES);
|
|
254
253
|
}
|
|
255
254
|
|
|
256
255
|
/**
|
|
@@ -290,8 +289,8 @@ class Ellipsoid {
|
|
|
290
289
|
* @returns {Vec3} -
|
|
291
290
|
*/
|
|
292
291
|
lonLatToCartesian(lonlat) {
|
|
293
|
-
var latrad =
|
|
294
|
-
lonrad =
|
|
292
|
+
var latrad = RADIANS * lonlat.lat,
|
|
293
|
+
lonrad = RADIANS * lonlat.lon;
|
|
295
294
|
|
|
296
295
|
var slt = Math.sin(latrad);
|
|
297
296
|
|
|
@@ -313,8 +312,8 @@ class Ellipsoid {
|
|
|
313
312
|
* @returns {Vec3} -
|
|
314
313
|
*/
|
|
315
314
|
lonLatToCartesianRes(lonlat, res) {
|
|
316
|
-
var latrad =
|
|
317
|
-
lonrad =
|
|
315
|
+
var latrad = RADIANS * lonlat.lat,
|
|
316
|
+
lonrad = RADIANS * lonlat.lon;
|
|
318
317
|
|
|
319
318
|
var slt = Math.sin(latrad);
|
|
320
319
|
|
|
@@ -337,8 +336,8 @@ class Ellipsoid {
|
|
|
337
336
|
* @returns {Vec3} -
|
|
338
337
|
*/
|
|
339
338
|
geodeticToCartesian(lon, lat, height = 0) {
|
|
340
|
-
var latrad =
|
|
341
|
-
lonrad =
|
|
339
|
+
var latrad = RADIANS * lat,
|
|
340
|
+
lonrad = RADIANS * lon;
|
|
342
341
|
|
|
343
342
|
var slt = Math.sin(latrad);
|
|
344
343
|
|
|
@@ -355,44 +354,72 @@ class Ellipsoid {
|
|
|
355
354
|
/**
|
|
356
355
|
* Gets Wgs84 geodetic coordiantes from cartesian ECEF.
|
|
357
356
|
* @public
|
|
358
|
-
* @param {Vec3}
|
|
357
|
+
* @param {Vec3} p - Cartesian coordinates.
|
|
359
358
|
* @returns {LonLat} -
|
|
360
359
|
*/
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
(
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
360
|
+
projToSurface(p) {
|
|
361
|
+
|
|
362
|
+
let pX = p.x || 0.0,
|
|
363
|
+
pY = p.y || 0.0,
|
|
364
|
+
pZ = p.z || 0.0;
|
|
365
|
+
|
|
366
|
+
let invRadii2X = this._invRadii2.x,
|
|
367
|
+
invRadii2Y = this._invRadii2.y,
|
|
368
|
+
invRadii2Z = this._invRadii2.z;
|
|
369
|
+
|
|
370
|
+
let x2 = pX * pX * invRadii2X,
|
|
371
|
+
y2 = pY * pY * invRadii2Y,
|
|
372
|
+
z2 = pZ * pZ * invRadii2Z;
|
|
373
|
+
|
|
374
|
+
let norm = x2 + y2 + z2;
|
|
375
|
+
let ratio = Math.sqrt(1.0 / norm);
|
|
376
|
+
let first = p.scaleTo(ratio);
|
|
377
|
+
|
|
378
|
+
if (norm < EPS1) {
|
|
379
|
+
return !Number.isFinite(ratio) ? new Vec3() : first
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
let lambda = ((1.0 - ratio) * p.length()) / first.mulA(this._invRadii2).length();
|
|
383
|
+
|
|
384
|
+
let m_X, m_Y, m_Z;
|
|
385
|
+
|
|
386
|
+
do {
|
|
387
|
+
m_X = 1.0 / (1.0 + lambda * invRadii2X);
|
|
388
|
+
m_Y = 1.0 / (1.0 + lambda * invRadii2Y);
|
|
389
|
+
m_Z = 1.0 / (1.0 + lambda * invRadii2Z);
|
|
390
|
+
|
|
391
|
+
let m_X2 = m_X * m_X,
|
|
392
|
+
m_Y2 = m_Y * m_Y,
|
|
393
|
+
m_Z2 = m_Z * m_Z;
|
|
394
|
+
|
|
395
|
+
let func = x2 * m_X2 + y2 * m_Y2 + z2 * m_Z2 - 1.0;
|
|
396
|
+
|
|
397
|
+
if (Math.abs(func) < EPS12) {
|
|
398
|
+
break;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
let m_X3 = m_X2 * m_X,
|
|
402
|
+
m_Y3 = m_Y2 * m_Y,
|
|
403
|
+
m_Z3 = m_Z2 * m_Z;
|
|
404
|
+
|
|
405
|
+
lambda += 0.5 * func / (x2 * m_X3 * invRadii2X + y2 * m_Y3 * invRadii2Y + z2 * m_Z3 * invRadii2Z);
|
|
406
|
+
|
|
407
|
+
} while (true); // eslint-disable-line
|
|
408
|
+
|
|
409
|
+
return new Vec3(pX * m_X, pY * m_Y, pZ * m_Z);
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
cartesianToLonLat(cart) {
|
|
413
|
+
|
|
414
|
+
let p = this.projToSurface(cart);
|
|
415
|
+
|
|
416
|
+
let n = this.getSurfaceNormal3v(p),
|
|
417
|
+
h = cart.sub(p);
|
|
418
|
+
|
|
392
419
|
return new LonLat(
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
420
|
+
Math.atan2(n.x, n.z) * DEGREES,
|
|
421
|
+
Math.asin(n.y) * DEGREES,
|
|
422
|
+
Math.sign(h.dot(cart)) * h.length()
|
|
396
423
|
);
|
|
397
424
|
}
|
|
398
425
|
|
|
@@ -403,11 +430,11 @@ class Ellipsoid {
|
|
|
403
430
|
* @return {Vec3} -
|
|
404
431
|
*/
|
|
405
432
|
getSurfaceNormal3v(coord) {
|
|
406
|
-
|
|
407
|
-
|
|
433
|
+
let r2 = this._invRadii2;
|
|
434
|
+
let nx = coord.x * r2.x,
|
|
408
435
|
ny = coord.y * r2.y,
|
|
409
436
|
nz = coord.z * r2.z;
|
|
410
|
-
|
|
437
|
+
let l = 1.0 / Math.sqrt(nx * nx + ny * ny + nz * nz);
|
|
411
438
|
return new Vec3(nx * l, ny * l, nz * l);
|
|
412
439
|
}
|
|
413
440
|
|
|
@@ -419,10 +446,10 @@ class Ellipsoid {
|
|
|
419
446
|
* @return {LonLat} -
|
|
420
447
|
*/
|
|
421
448
|
getBearingDestination(lonLat1, bearing = 0.0, distance = 0) {
|
|
422
|
-
bearing = bearing *
|
|
449
|
+
bearing = bearing * RADIANS;
|
|
423
450
|
var nlon = ((lonLat1.lon + 540) % 360) - 180;
|
|
424
|
-
var f1 = lonLat1.lat *
|
|
425
|
-
l1 = nlon *
|
|
451
|
+
var f1 = lonLat1.lat * RADIANS,
|
|
452
|
+
l1 = nlon * RADIANS;
|
|
426
453
|
var dR = distance / this._a;
|
|
427
454
|
var f2 = Math.asin(
|
|
428
455
|
Math.sin(f1) * Math.cos(dR) + Math.cos(f1) * Math.sin(dR) * Math.cos(bearing)
|
|
@@ -433,8 +460,8 @@ class Ellipsoid {
|
|
|
433
460
|
Math.sin(bearing) * Math.sin(dR) * Math.cos(f1),
|
|
434
461
|
Math.cos(dR) - Math.sin(f1) * Math.sin(f2)
|
|
435
462
|
)) *
|
|
436
|
-
|
|
437
|
-
f2 *
|
|
463
|
+
DEGREES,
|
|
464
|
+
f2 * DEGREES
|
|
438
465
|
);
|
|
439
466
|
}
|
|
440
467
|
|
|
@@ -445,14 +472,14 @@ class Ellipsoid {
|
|
|
445
472
|
* @return {number} Distance between points.
|
|
446
473
|
*/
|
|
447
474
|
getGreatCircleDistance(lonLat1, lonLat2) {
|
|
448
|
-
var dLat = (lonLat2.lat - lonLat1.lat) *
|
|
449
|
-
var dLon = (lonLat2.lon - lonLat1.lon) *
|
|
475
|
+
var dLat = (lonLat2.lat - lonLat1.lat) * RADIANS;
|
|
476
|
+
var dLon = (lonLat2.lon - lonLat1.lon) * RADIANS;
|
|
450
477
|
var a =
|
|
451
478
|
Math.sin(dLat / 2.0) * Math.sin(dLat / 2.0) +
|
|
452
479
|
Math.sin(dLon / 2.0) *
|
|
453
480
|
Math.sin(dLon / 2) *
|
|
454
|
-
Math.cos(lonLat1.lat *
|
|
455
|
-
Math.cos(lonLat2.lat *
|
|
481
|
+
Math.cos(lonLat1.lat * RADIANS) *
|
|
482
|
+
Math.cos(lonLat2.lat * RADIANS);
|
|
456
483
|
return this._a * 2.0 * Math.atan2(Math.sqrt(a), Math.sqrt(1.0 - a));
|
|
457
484
|
}
|
|
458
485
|
|
|
@@ -469,10 +496,10 @@ class Ellipsoid {
|
|
|
469
496
|
b = this._b,
|
|
470
497
|
f = 1.0 / this._f,
|
|
471
498
|
s = dist,
|
|
472
|
-
alpha1 = brng *
|
|
499
|
+
alpha1 = brng * RADIANS,
|
|
473
500
|
sinAlpha1 = Math.sin(alpha1),
|
|
474
501
|
cosAlpha1 = Math.cos(alpha1),
|
|
475
|
-
tanU1 = (1 - f) * Math.tan(lat1 *
|
|
502
|
+
tanU1 = (1 - f) * Math.tan(lat1 * RADIANS),
|
|
476
503
|
cosU1 = 1 / Math.sqrt(1 + tanU1 * tanU1),
|
|
477
504
|
sinU1 = tanU1 * cosU1,
|
|
478
505
|
sigma1 = Math.atan2(tanU1, cosAlpha1),
|
|
@@ -520,7 +547,7 @@ class Ellipsoid {
|
|
|
520
547
|
sinSigma *
|
|
521
548
|
(cos2SigmaM + C * cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM))),
|
|
522
549
|
revAz = Math.atan2(sinAlpha, -tmp); // final bearing
|
|
523
|
-
return new LonLat(lon1 + L *
|
|
550
|
+
return new LonLat(lon1 + L * DEGREES, lat2 * DEGREES);
|
|
524
551
|
}
|
|
525
552
|
|
|
526
553
|
/**
|
|
@@ -555,7 +582,7 @@ class Ellipsoid {
|
|
|
555
582
|
|
|
556
583
|
let eps = Math.abs(qw2 - product);
|
|
557
584
|
|
|
558
|
-
if (eps >
|
|
585
|
+
if (eps > EPS15 && qw2 < product) {
|
|
559
586
|
// Imaginary roots (0 intersections).
|
|
560
587
|
return null;
|
|
561
588
|
} else if (qw2 > product) {
|
|
@@ -594,4 +621,4 @@ class Ellipsoid {
|
|
|
594
621
|
}
|
|
595
622
|
}
|
|
596
623
|
|
|
597
|
-
export { Ellipsoid };
|
|
624
|
+
export { Ellipsoid };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module og/ellipsoid/wgs84
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
"use strict";
|
|
6
|
-
|
|
7
|
-
import { Ellipsoid } from "./Ellipsoid.js";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* WGS84 ellipsoid object.
|
|
11
|
-
* @type {Ellipsoid}
|
|
12
|
-
*/
|
|
13
|
-
export const wgs84 = new Ellipsoid(6378137.0, 6356752.
|
|
1
|
+
/**
|
|
2
|
+
* @module og/ellipsoid/wgs84
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
import { Ellipsoid } from "./Ellipsoid.js";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* WGS84 ellipsoid object.
|
|
11
|
+
* @type {Ellipsoid}
|
|
12
|
+
*/
|
|
13
|
+
export const wgs84 = new Ellipsoid(6378137.0, 6356752.3142451793); // Equitorial Radius (m), Polar Radius (m)
|
package/src/og/entity/Entity.js
CHANGED
|
@@ -338,9 +338,9 @@ class Entity {
|
|
|
338
338
|
setCartesian(x, y, z) {
|
|
339
339
|
let p = this._cartesian;
|
|
340
340
|
|
|
341
|
-
p.x = x;
|
|
342
|
-
p.y = y;
|
|
343
|
-
p.z = z;
|
|
341
|
+
p.x = x || 0.0;
|
|
342
|
+
p.y = y || 0.0;
|
|
343
|
+
p.z = z || 0.0;
|
|
344
344
|
|
|
345
345
|
// billboards
|
|
346
346
|
this.billboard && this.billboard.setPosition3v(p);
|
|
@@ -382,9 +382,9 @@ class Entity {
|
|
|
382
382
|
_setCartesian3vSilent(cartesian, skipLonLat) {
|
|
383
383
|
let p = this._cartesian;
|
|
384
384
|
|
|
385
|
-
p.x = cartesian.x;
|
|
386
|
-
p.y = cartesian.y;
|
|
387
|
-
p.z = cartesian.z;
|
|
385
|
+
p.x = cartesian.x || 0.0;
|
|
386
|
+
p.y = cartesian.y || 0.0;
|
|
387
|
+
p.z = cartesian.z || 0.0;
|
|
388
388
|
|
|
389
389
|
// billboards
|
|
390
390
|
this.billboard && this.billboard.setPosition3v(p);
|
|
@@ -438,13 +438,40 @@ class Entity {
|
|
|
438
438
|
|
|
439
439
|
let ec = this._entityCollection;
|
|
440
440
|
if (ec && ec.renderNode && ec.renderNode.ellipsoid) {
|
|
441
|
-
if (Math.abs(
|
|
442
|
-
this._lonlatMerc =
|
|
441
|
+
if (Math.abs(l.lat) < mercator.MAX_LAT) {
|
|
442
|
+
this._lonlatMerc = l.forwardMercator();
|
|
443
443
|
} else {
|
|
444
444
|
this._lonlatMerc = null;
|
|
445
445
|
}
|
|
446
446
|
|
|
447
|
-
ec.renderNode.ellipsoid.lonLatToCartesianRes(
|
|
447
|
+
ec.renderNode.ellipsoid.lonLatToCartesianRes(l, this._cartesian);
|
|
448
|
+
this.setCartesian3v(this._cartesian);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* Sets geodetic coordinates of the entity point object.
|
|
454
|
+
* @public
|
|
455
|
+
* @param {number} lon - Longitude.
|
|
456
|
+
* @param {number} lat - Latitude
|
|
457
|
+
* @param {number} [height] - Height
|
|
458
|
+
*/
|
|
459
|
+
setLonLat2(lon, lat, height) {
|
|
460
|
+
let l = this._lonlat;
|
|
461
|
+
|
|
462
|
+
l.lon = lon;
|
|
463
|
+
l.lat = lat;
|
|
464
|
+
l.height = height != undefined ? height : l.height;
|
|
465
|
+
|
|
466
|
+
let ec = this._entityCollection;
|
|
467
|
+
if (ec && ec.renderNode && ec.renderNode.ellipsoid) {
|
|
468
|
+
if (Math.abs(l.lat) < mercator.MAX_LAT) {
|
|
469
|
+
this._lonlatMerc = l.forwardMercator();
|
|
470
|
+
} else {
|
|
471
|
+
this._lonlatMerc = null;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
ec.renderNode.ellipsoid.lonLatToCartesianRes(l, this._cartesian);
|
|
448
475
|
this.setCartesian3v(this._cartesian);
|
|
449
476
|
}
|
|
450
477
|
}
|
|
@@ -505,9 +505,7 @@ class EntityCollection {
|
|
|
505
505
|
this.billboardHandler.setRenderer(renderNode.renderer);
|
|
506
506
|
this.labelHandler.setRenderer(renderNode.renderer);
|
|
507
507
|
this.rayHandler.setRenderer(renderNode.renderer);
|
|
508
|
-
|
|
509
508
|
this.geoObjectHandler.setRenderNode(renderNode);
|
|
510
|
-
|
|
511
509
|
this.shapeHandler.setRenderNode(renderNode);
|
|
512
510
|
this.polylineHandler.setRenderNode(renderNode);
|
|
513
511
|
this.pointCloudHandler.setRenderNode(renderNode);
|