@openglobus/og 0.13.12 → 0.14.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/README.md +1 -4
- package/css/og.css +1 -1
- 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 +2 -2
- package/src/og/Globe.js +14 -4
- package/src/og/camera/Camera.js +7 -7
- package/src/og/camera/PlanetCamera.js +1 -1
- package/src/og/control/LayerSwitcher.js +48 -31
- package/src/og/control/MouseNavigation.js +2 -2
- package/src/og/control/ScaleControl.js +30 -10
- package/src/og/control/SimpleSkyBackground.js +184 -0
- package/src/og/control/Sun.js +3 -2
- package/src/og/ellipsoid/Ellipsoid.js +119 -92
- package/src/og/ellipsoid/wgs84.js +13 -13
- package/src/og/entity/Entity.js +3 -3
- 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 +106 -95
- package/src/og/layer/GeoVideo.js +1 -0
- package/src/og/layer/Layer.js +62 -3
- package/src/og/layer/XYZ.js +4 -3
- 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/EarthQuadTreeStrategy.js +29 -0
- package/src/og/quadTree/MarsQuadTreeStrategy.js +27 -0
- package/src/og/quadTree/Node.js +55 -218
- package/src/og/quadTree/QuadTreeStrategy.js +93 -0
- package/src/og/quadTree/Wgs84QuadTreeStrategy.js +26 -0
- package/src/og/renderer/Renderer.js +13 -12
- package/src/og/renderer/RendererEvents.js +1065 -1065
- package/src/og/scene/Planet.js +84 -273
- package/src/og/segment/Segment.js +18 -25
- package/src/og/segment/SegmentLonLat.js +34 -31
- package/src/og/segment/SegmentLonLatWgs84.js +41 -0
- package/src/og/shaders/ray.js +13 -6
- package/src/og/shaders/toneMapping.js +5 -5
- package/src/og/terrain/GlobusTerrain.js +3 -2
- package/src/og/terrain/MapboxTerrain.js +231 -52
- package/src/og/utils/quadTreeType.js +11 -0
- package/src/og/utils/shared.js +942 -942
- package/src/og/webgl/Handler.js +22 -9
- package/types/Globe.d.ts +7 -0
- package/types/camera/Camera.d.ts +3 -3
- package/types/camera/PlanetCamera.d.ts +1 -1
- package/types/control/LayerSwitcher.d.ts +1 -1
- package/types/control/ScaleControl.d.ts +2 -1
- package/types/control/SimpleSkyBackground.d.ts +11 -0
- package/types/control/Sun.d.ts +2 -1
- package/types/ellipsoid/Ellipsoid.d.ts +3 -2
- package/types/entity/Ray.d.ts +0 -3
- package/types/entity/RayHandler.d.ts +0 -4
- package/types/index.d.ts +6 -1
- package/types/layer/Layer.d.ts +8 -0
- 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/EarthQuadTreeStrategy.d.ts +3 -0
- package/types/quadTree/MarsQuadTreeStrategy.d.ts +3 -0
- package/types/quadTree/Node.d.ts +0 -1
- package/types/quadTree/QuadTreeStrategy.d.ts +21 -0
- package/types/quadTree/Wgs84QuadTreeStrategy.d.ts +3 -0
- package/types/renderer/Renderer.d.ts +1 -1
- package/types/scene/Planet.d.ts +6 -24
- package/types/segment/Segment.d.ts +4 -4
- package/types/segment/SegmentLonLat.d.ts +6 -2
- package/types/segment/SegmentLonLatWgs84.d.ts +4 -0
- package/types/terrain/MapboxTerrain.d.ts +2 -1
- package/types/utils/quadTreeType.d.ts +8 -0
- package/types/webgl/Handler.d.ts +4 -1
package/src/og/math/Vec3.js
CHANGED
|
@@ -39,38 +39,47 @@ export class Vec3 {
|
|
|
39
39
|
static get UP() {
|
|
40
40
|
return new Vec3(0, 1, 0);
|
|
41
41
|
}
|
|
42
|
+
|
|
42
43
|
/** @const */
|
|
43
44
|
static get DOWN() {
|
|
44
45
|
return new Vec3(0, -1, 0);
|
|
45
46
|
}
|
|
47
|
+
|
|
46
48
|
/** @const */
|
|
47
49
|
static get RIGHT() {
|
|
48
50
|
return new Vec3(1, 0, 0);
|
|
49
51
|
}
|
|
52
|
+
|
|
50
53
|
/** @const */
|
|
51
54
|
static get LEFT() {
|
|
52
55
|
return new Vec3(-1, 0, 0);
|
|
53
56
|
}
|
|
57
|
+
|
|
54
58
|
/** @const */
|
|
55
59
|
static get FORWARD() {
|
|
56
60
|
return new Vec3(0, 0, -1);
|
|
57
61
|
}
|
|
62
|
+
|
|
58
63
|
/** @const */
|
|
59
64
|
static get BACKWARD() {
|
|
60
65
|
return new Vec3(0, 0, 1);
|
|
61
66
|
}
|
|
67
|
+
|
|
62
68
|
/** @const */
|
|
63
69
|
static get ZERO() {
|
|
64
70
|
return new Vec3();
|
|
65
71
|
}
|
|
72
|
+
|
|
66
73
|
/** @const */
|
|
67
74
|
static get UNIT_X() {
|
|
68
75
|
return new Vec3(1, 0, 0);
|
|
69
76
|
}
|
|
77
|
+
|
|
70
78
|
/** @const */
|
|
71
79
|
static get UNIT_Y() {
|
|
72
80
|
return new Vec3(0, 1, 0);
|
|
73
81
|
}
|
|
82
|
+
|
|
74
83
|
/** @const */
|
|
75
84
|
static get UNIT_Z() {
|
|
76
85
|
return new Vec3(0, 0, 1);
|
|
@@ -231,9 +240,7 @@ export class Vec3 {
|
|
|
231
240
|
* @returns {Vec3} -
|
|
232
241
|
*/
|
|
233
242
|
static scale(a, scale) {
|
|
234
|
-
|
|
235
|
-
res.scale(scale);
|
|
236
|
-
return res;
|
|
243
|
+
return a.scaleTo(scale);
|
|
237
244
|
}
|
|
238
245
|
|
|
239
246
|
/**
|
|
@@ -314,6 +321,18 @@ export class Vec3 {
|
|
|
314
321
|
return res;
|
|
315
322
|
}
|
|
316
323
|
|
|
324
|
+
static length2(a) {
|
|
325
|
+
return a.length2();
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
static length(a) {
|
|
329
|
+
return a.length();
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
static dot(a, b) {
|
|
333
|
+
return a.dot(b);
|
|
334
|
+
}
|
|
335
|
+
|
|
317
336
|
/**
|
|
318
337
|
* Converts to 4d vector, Fourth value is 1.0.
|
|
319
338
|
* @public
|
|
@@ -372,13 +391,13 @@ export class Vec3 {
|
|
|
372
391
|
|
|
373
392
|
/**
|
|
374
393
|
* Copy input vector's values.
|
|
375
|
-
* @param {Vec3}
|
|
394
|
+
* @param {Vec3} p - Vector to copy.
|
|
376
395
|
* @returns {Vec3} -
|
|
377
396
|
*/
|
|
378
|
-
copy(
|
|
379
|
-
this.x =
|
|
380
|
-
this.y =
|
|
381
|
-
this.z =
|
|
397
|
+
copy(p) {
|
|
398
|
+
this.x = p.x;
|
|
399
|
+
this.y = p.y;
|
|
400
|
+
this.z = p.z;
|
|
382
401
|
return this;
|
|
383
402
|
}
|
|
384
403
|
|
|
@@ -412,47 +431,47 @@ export class Vec3 {
|
|
|
412
431
|
/**
|
|
413
432
|
* Adds vector to the current.
|
|
414
433
|
* @public
|
|
415
|
-
* @param {Vec3}
|
|
434
|
+
* @param {Vec3} p - Point to add.
|
|
416
435
|
* @returns {Vec3} -
|
|
417
436
|
*/
|
|
418
|
-
addA(
|
|
419
|
-
this.x +=
|
|
420
|
-
this.y +=
|
|
421
|
-
this.z +=
|
|
437
|
+
addA(p) {
|
|
438
|
+
this.x += p.x;
|
|
439
|
+
this.y += p.y;
|
|
440
|
+
this.z += p.z;
|
|
422
441
|
return this;
|
|
423
442
|
}
|
|
424
443
|
|
|
425
444
|
/**
|
|
426
445
|
* Gets two vectors summarization.
|
|
427
446
|
* @public
|
|
428
|
-
* @param {Vec3}
|
|
447
|
+
* @param {Vec3} p - Vector to add.
|
|
429
448
|
* @returns {Vec3} Returns a sum vector.
|
|
430
449
|
*/
|
|
431
|
-
add(
|
|
432
|
-
return new Vec3(this.x +
|
|
450
|
+
add(p) {
|
|
451
|
+
return new Vec3(this.x + p.x, this.y + p.y, this.z + p.z);
|
|
433
452
|
}
|
|
434
453
|
|
|
435
454
|
/**
|
|
436
455
|
* Subtract vector from the current.
|
|
437
456
|
* @public
|
|
438
|
-
* @param {Vec3}
|
|
457
|
+
* @param {Vec3} p - Subtract vector.
|
|
439
458
|
* @returns {Vec3} -
|
|
440
459
|
*/
|
|
441
|
-
subA(
|
|
442
|
-
this.x -=
|
|
443
|
-
this.y -=
|
|
444
|
-
this.z -=
|
|
460
|
+
subA(p) {
|
|
461
|
+
this.x -= p.x;
|
|
462
|
+
this.y -= p.y;
|
|
463
|
+
this.z -= p.z;
|
|
445
464
|
return this;
|
|
446
465
|
}
|
|
447
466
|
|
|
448
467
|
/**
|
|
449
468
|
* Gets vector subtraction.
|
|
450
469
|
* @public
|
|
451
|
-
* @param {Vec3}
|
|
470
|
+
* @param {Vec3} p - Subtract vector.
|
|
452
471
|
* @return {Vec3} Returns new instance of a subtraction
|
|
453
472
|
*/
|
|
454
|
-
sub(
|
|
455
|
-
return new Vec3(this.x -
|
|
473
|
+
sub(p) {
|
|
474
|
+
return new Vec3(this.x - p.x, this.y - p.y, this.z - p.z);
|
|
456
475
|
}
|
|
457
476
|
|
|
458
477
|
/**
|
|
@@ -527,11 +546,11 @@ export class Vec3 {
|
|
|
527
546
|
/**
|
|
528
547
|
* Gets vectors dot production.
|
|
529
548
|
* @public
|
|
530
|
-
* @param {Vec3}
|
|
549
|
+
* @param {Vec3} a - Another vector.
|
|
531
550
|
* @returns {number} -
|
|
532
551
|
*/
|
|
533
|
-
dot(
|
|
534
|
-
return
|
|
552
|
+
dot(a) {
|
|
553
|
+
return a.x * this.x + a.y * this.y + a.z * this.z;
|
|
535
554
|
}
|
|
536
555
|
|
|
537
556
|
/**
|
|
@@ -696,26 +715,26 @@ export class Vec3 {
|
|
|
696
715
|
/**
|
|
697
716
|
* Gets distance to point.
|
|
698
717
|
* @public
|
|
699
|
-
* @param {Vec3}
|
|
718
|
+
* @param {Vec3} p - Distant point.
|
|
700
719
|
* @returns {number} -
|
|
701
720
|
*/
|
|
702
|
-
distance(
|
|
703
|
-
let dx = this.x -
|
|
704
|
-
dy = this.y -
|
|
705
|
-
dz = this.z -
|
|
721
|
+
distance(p) {
|
|
722
|
+
let dx = this.x - p.x,
|
|
723
|
+
dy = this.y - p.y,
|
|
724
|
+
dz = this.z - p.z;
|
|
706
725
|
return Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
707
726
|
}
|
|
708
727
|
|
|
709
728
|
/**
|
|
710
729
|
* Gets square distance to point.
|
|
711
730
|
* @public
|
|
712
|
-
* @param {Vec3}
|
|
731
|
+
* @param {Vec3} p - Distant point.
|
|
713
732
|
* @returns {number} -
|
|
714
733
|
*/
|
|
715
|
-
distance2(
|
|
716
|
-
let dx = this.x -
|
|
717
|
-
dy = this.y -
|
|
718
|
-
dz = this.z -
|
|
734
|
+
distance2(p) {
|
|
735
|
+
let dx = this.x - p.x,
|
|
736
|
+
dy = this.y - p.y,
|
|
737
|
+
dz = this.z - p.z;
|
|
719
738
|
return dx * dx + dy * dy + dz * dz;
|
|
720
739
|
}
|
|
721
740
|
|
package/src/og/math/Vec4.js
CHANGED
|
@@ -106,9 +106,8 @@ export class Vec4 {
|
|
|
106
106
|
* Converts vector to a number array.
|
|
107
107
|
* @public
|
|
108
108
|
* @returns {Array.<number>} - (exactly 4 entries)
|
|
109
|
-
* @deprecated
|
|
110
109
|
*/
|
|
111
|
-
|
|
110
|
+
toArray() {
|
|
112
111
|
return [this.x, this.y, this.z, this.w];
|
|
113
112
|
}
|
|
114
113
|
|
|
@@ -117,8 +116,8 @@ export class Vec4 {
|
|
|
117
116
|
* @public
|
|
118
117
|
* @returns {Array.<number>} - (exactly 4 entries)
|
|
119
118
|
*/
|
|
120
|
-
|
|
121
|
-
return [this.x, this.y, this.z
|
|
119
|
+
toArray3() {
|
|
120
|
+
return [this.x, this.y, this.z];
|
|
122
121
|
}
|
|
123
122
|
|
|
124
123
|
/**
|
package/src/og/math.js
CHANGED
|
@@ -49,26 +49,26 @@ export const DEGREES_TO_HOURS = 1.0 / 15.0;
|
|
|
49
49
|
/** @const */
|
|
50
50
|
export const SQRT_HALF = Math.sqrt(0.5);
|
|
51
51
|
|
|
52
|
-
export const
|
|
53
|
-
export const
|
|
54
|
-
export const
|
|
55
|
-
export const
|
|
56
|
-
export const
|
|
57
|
-
export const
|
|
58
|
-
export const
|
|
59
|
-
export const
|
|
60
|
-
export const
|
|
61
|
-
export const
|
|
62
|
-
export const
|
|
63
|
-
export const
|
|
64
|
-
export const
|
|
65
|
-
export const
|
|
66
|
-
export const
|
|
67
|
-
export const
|
|
68
|
-
export const
|
|
69
|
-
export const
|
|
70
|
-
export const
|
|
71
|
-
export const
|
|
52
|
+
export const EPS1 = 0.1;
|
|
53
|
+
export const EPS2 = 0.01;
|
|
54
|
+
export const EPS3 = 0.001;
|
|
55
|
+
export const EPS4 = 0.0001;
|
|
56
|
+
export const EPS5 = 0.00001;
|
|
57
|
+
export const EPS6 = 0.000001;
|
|
58
|
+
export const EPS7 = 1e-7;
|
|
59
|
+
export const EPS8 = 1e-8;
|
|
60
|
+
export const EPS9 = 1e-9;
|
|
61
|
+
export const EPS10 = 1e-10;
|
|
62
|
+
export const EPS11 = 1e-11;
|
|
63
|
+
export const EPS12 = 1e-12;
|
|
64
|
+
export const EPS13 = 1e-13;
|
|
65
|
+
export const EPS14 = 1e-14;
|
|
66
|
+
export const EPS15 = 1e-15;
|
|
67
|
+
export const EPS16 = 1e-16;
|
|
68
|
+
export const EPS17 = 1e-17;
|
|
69
|
+
export const EPS18 = 1e-18;
|
|
70
|
+
export const EPS19 = 1e-19;
|
|
71
|
+
export const EPS20 = 1e-20;
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
74
|
* The log function returns the power to which the base value has to be raised to produce n.
|
|
@@ -201,7 +201,7 @@ export function mod(m, n) {
|
|
|
201
201
|
*/
|
|
202
202
|
export function zeroTwoPI(a) {
|
|
203
203
|
const res = mod(a, TWO_PI);
|
|
204
|
-
if (Math.abs(res) <
|
|
204
|
+
if (Math.abs(res) < EPS14 && Math.abs(a) > EPS14) {
|
|
205
205
|
return TWO_PI;
|
|
206
206
|
}
|
|
207
207
|
return res;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { QuadTreeStrategy } from "./QuadTreeStrategy.js"
|
|
3
|
+
import * as mercator from "../mercator.js";
|
|
4
|
+
import { Segment } from "../segment/Segment.js";
|
|
5
|
+
import { SegmentLonLat } from "../segment/SegmentLonLat.js";
|
|
6
|
+
import * as quadTree from "../quadTree/quadTree.js";
|
|
7
|
+
import { Extent } from "../Extent.js";
|
|
8
|
+
import { Node } from "../quadTree/Node.js";
|
|
9
|
+
|
|
10
|
+
export class EarthQuadTreeStrategy extends QuadTreeStrategy {
|
|
11
|
+
constructor(options = {}) {
|
|
12
|
+
super(options);
|
|
13
|
+
this.name = "earth";
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
init() {
|
|
17
|
+
this._quadTreeList = [
|
|
18
|
+
new Node(Segment, this.planet, quadTree.NW, null, 0, 0,
|
|
19
|
+
Extent.createFromArray([-20037508.34, -20037508.34, 20037508.34, 20037508.34])
|
|
20
|
+
),
|
|
21
|
+
new Node(SegmentLonLat, this.planet, quadTree.NW, null, 0, 0,
|
|
22
|
+
Extent.createFromArray([-180, mercator.MAX_LAT, 180, 90])
|
|
23
|
+
),
|
|
24
|
+
new Node(SegmentLonLat, this.planet, quadTree.NW, null, 0, 0,
|
|
25
|
+
Extent.createFromArray([-180, -90, 180, mercator.MIN_LAT])
|
|
26
|
+
)
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { QuadTreeStrategy } from "./QuadTreeStrategy.js"
|
|
3
|
+
import { SegmentLonLatWgs84 } from "../segment/SegmentLonLatWgs84.js";
|
|
4
|
+
import * as quadTree from "../quadTree/quadTree.js";
|
|
5
|
+
import { Extent } from "../Extent.js";
|
|
6
|
+
import { Node } from "../quadTree/Node.js";
|
|
7
|
+
import { EPSG4326 } from "../proj/EPSG4326.js";
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export class MarsQuadTreeStrategy extends QuadTreeStrategy {
|
|
11
|
+
constructor(options = {}) {
|
|
12
|
+
super(options);
|
|
13
|
+
this.name = "mars";
|
|
14
|
+
this.projection = EPSG4326;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
init() {
|
|
18
|
+
let earthQuadTreeSouth = new Node(SegmentLonLatWgs84, this.planet, quadTree.NW, null, 0, 0,
|
|
19
|
+
Extent.createFromArray([-180, -90, 0, 90])
|
|
20
|
+
);
|
|
21
|
+
let earthQuadTreeWest = new Node(SegmentLonLatWgs84, this.planet, quadTree.NW, null, 0, 0,
|
|
22
|
+
Extent.createFromArray([0, -90, 180, 90])
|
|
23
|
+
);
|
|
24
|
+
this._quadTreeList.push(earthQuadTreeSouth);
|
|
25
|
+
this._quadTreeList.push(earthQuadTreeWest);
|
|
26
|
+
}
|
|
27
|
+
}
|