@openglobus/og 0.11.5 → 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 +5 -7
- package/src/og/Clock.js +6 -10
- package/src/og/Events.js +5 -7
- package/src/og/Extent.js +73 -32
- package/src/og/ImageCanvas.js +18 -15
- package/src/og/LonLat.js +13 -10
- package/src/og/Popup.js +18 -17
- package/src/og/QueueArray.js +3 -4
- package/src/og/Rectangle.js +4 -6
- package/src/og/Stack.js +2 -4
- package/src/og/ajax.js +20 -14
- package/src/og/astro/earth.js +21 -15
- package/src/og/bv/Box.js +2 -3
- package/src/og/bv/Sphere.js +10 -7
- package/src/og/camera/Frustum.js +19 -12
- package/src/og/camera/PlanetCamera.js +0 -1
- package/src/og/control/CompassButton.js +1 -2
- package/src/og/control/Control.js +7 -9
- package/src/og/control/DebugInfo.js +0 -1
- package/src/og/control/KeyboardNavigation.js +9 -9
- package/src/og/control/LayerSwitcher.js +21 -20
- package/src/og/control/SegmentBoundVisualization.js +5 -6
- package/src/og/control/ShowFps.js +12 -7
- package/src/og/control/SimpleNavigation.js +5 -7
- package/src/og/control/Sun.js +22 -12
- package/src/og/control/ToggleWireframe.js +3 -3
- package/src/og/control/TouchNavigation.js +43 -32
- package/src/og/control/ZoomControl.js +40 -24
- package/src/og/ellipsoid/Ellipsoid.js +148 -56
- package/src/og/ellipsoid/wgs84.js +3 -3
- package/src/og/entity/BaseBillboard.js +65 -14
- package/src/og/entity/Billboard.js +9 -5
- package/src/og/entity/BillboardHandler.js +310 -64
- package/src/og/entity/Entity.js +39 -1
- package/src/og/entity/EntityCollection.js +47 -24
- package/src/og/entity/GeoObject.js +228 -0
- package/src/og/entity/GeoObjectHandler.js +910 -0
- package/src/og/entity/GeometryHandler.js +595 -123
- package/src/og/entity/Label.js +53 -18
- package/src/og/entity/LabelHandler.js +42 -244
- package/src/og/entity/LabelWorker.js +213 -0
- package/src/og/entity/Object3d.js +504 -0
- package/src/og/entity/PointCloud.js +76 -28
- package/src/og/entity/PointCloudHandler.js +5 -5
- package/src/og/entity/Ray.js +49 -16
- package/src/og/entity/Strip.js +72 -43
- package/src/og/entity/StripHandler.js +23 -23
- package/src/og/layer/BaseGeoImage.js +50 -19
- package/src/og/layer/CanvasTiles.js +16 -16
- package/src/og/layer/GeoImage.js +6 -6
- package/src/og/layer/KML.js +55 -33
- package/src/og/layer/Layer.js +3 -3
- package/src/og/layer/Vector.js +94 -48
- package/src/og/layer/WMS.js +33 -16
- package/src/og/light/LightSource.js +19 -12
- package/src/og/math/Mat3.js +24 -12
- package/src/og/math/Mat4.js +603 -603
- package/src/og/math/Plane.js +19 -18
- package/src/og/math/Ray.js +17 -12
- package/src/og/math/Vec2.js +24 -14
- package/src/og/math/Vec3.js +60 -30
- package/src/og/math/coder.js +7 -7
- package/src/og/proj/EPSG3857.js +3 -3
- package/src/og/proj/EPSG4326.js +3 -3
- package/src/og/proj/Proj.js +2 -4
- package/src/og/quadTree/Node.js +31 -17
- package/src/og/renderer/Renderer.js +23 -6
- package/src/og/renderer/RendererEvents.js +1 -1
- package/src/og/scene/BaseNode.js +2 -3
- package/src/og/scene/Planet.js +2 -2
- package/src/og/scene/RenderNode.js +15 -8
- package/src/og/shaders/geoObject.js +211 -0
- package/src/og/shaders/pointCloud.js +41 -41
- package/src/og/shaders/shape.js +12 -18
- package/src/og/shaders/skybox.js +36 -36
- package/src/og/shapes/BaseShape.js +107 -35
- package/src/og/shapes/Icosphere.js +25 -10
- package/src/og/shapes/Sphere.js +8 -11
- package/src/og/utils/TextureAtlas.js +16 -18
- package/src/og/utils/shared.js +1 -1
- package/src/og/webgl/Handler.js +68 -49
- package/src/og/webgl/Multisample.js +44 -16
- package/src/og/webgl/Program.js +78 -33
- package/src/og/webgl/callbacks.js +3 -3
- package/types/Deferred.d.ts +1 -1
- package/types/Events.d.ts +2 -2
- package/types/Extent.d.ts +1 -1
- package/types/Rectangle.d.ts +1 -1
- package/types/ajax.d.ts +1 -1
- package/types/bv/Box.d.ts +1 -1
- package/types/bv/Sphere.d.ts +1 -1
- package/types/camera/Camera.d.ts +5 -5
- package/types/camera/Frustum.d.ts +6 -6
- package/types/camera/PlanetCamera.d.ts +8 -8
- package/types/control/Control.d.ts +1 -1
- package/types/control/EarthCoordinates.d.ts +1 -1
- package/types/control/Sun.d.ts +1 -1
- package/types/entity/BaseBillboard.d.ts +15 -8
- package/types/entity/Entity.d.ts +24 -9
- package/types/entity/EntityCollection.d.ts +15 -9
- package/types/entity/GeoObject.d.ts +111 -0
- package/types/entity/GeoObjectHandler.d.ts +77 -0
- package/types/entity/Geometry.d.ts +1 -1
- package/types/entity/GeometryHandler.d.ts +1 -1
- package/types/entity/Label.d.ts +3 -3
- package/types/entity/LabelHandler.d.ts +2 -0
- package/types/entity/LabelWorker.d.ts +9 -0
- package/types/entity/PointCloud.d.ts +1 -1
- package/types/entity/Polyline.d.ts +5 -5
- package/types/entity/Ray.d.ts +1 -1
- package/types/entity/Strip.d.ts +1 -1
- package/types/layer/BaseGeoImage.d.ts +3 -3
- package/types/layer/CanvasTiles.d.ts +5 -5
- package/types/layer/GeoImage.d.ts +1 -1
- package/types/layer/GeoVideo.d.ts +1 -1
- package/types/layer/Layer.d.ts +5 -5
- package/types/layer/Vector.d.ts +9 -9
- package/types/layer/XYZ.d.ts +3 -3
- package/types/light/LightSource.d.ts +7 -7
- package/types/math/Plane.d.ts +1 -1
- package/types/math/Ray.d.ts +1 -1
- package/types/math/Vec2.d.ts +34 -34
- package/types/math/Vec3.d.ts +1 -1
- package/types/math/Vec4.d.ts +1 -1
- package/types/math/coder.d.ts +1 -1
- package/types/math.d.ts +1 -1
- package/types/proj/Proj.d.ts +2 -2
- package/types/quadTree/Node.d.ts +1 -1
- package/types/renderer/Renderer.d.ts +12 -10
- package/types/renderer/RendererEvents.d.ts +1 -1
- package/types/scene/BaseNode.d.ts +4 -4
- package/types/scene/Planet.d.ts +40 -40
- package/types/scene/RenderNode.d.ts +9 -9
- package/types/segment/Segment.d.ts +9 -9
- package/types/shaders/geoObject.d.ts +3 -0
- package/types/shapes/BaseShape.d.ts +5 -5
- package/types/terrain/EmptyTerrain.d.ts +2 -2
- package/types/terrain/GlobusTerrain.d.ts +4 -4
- package/types/utils/TextureAtlas.d.ts +4 -4
- package/types/utils/shared.d.ts +9 -9
- package/types/webgl/Framebuffer.d.ts +1 -1
- package/types/webgl/Handler.d.ts +16 -7
- package/types/webgl/Multisample.d.ts +2 -2
- package/types/webgl/Program.d.ts +6 -0
- package/types/webgl/ProgramController.d.ts +1 -1
package/src/og/math/Plane.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
import * as math from
|
|
4
|
-
import { Vec3 } from
|
|
3
|
+
import * as math from "../math.js";
|
|
4
|
+
import { Vec3 } from "./Vec3.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Plane class.
|
|
@@ -11,8 +11,8 @@ import { Vec3 } from './Vec3.js';
|
|
|
11
11
|
*/
|
|
12
12
|
class Plane {
|
|
13
13
|
constructor(p, n) {
|
|
14
|
-
this.p =
|
|
15
|
-
this.n =
|
|
14
|
+
this.p = p ? p.clone() : new Vec3();
|
|
15
|
+
this.n = n ? n.clone() : this.p.normal();
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
set(p, n) {
|
|
@@ -47,27 +47,28 @@ class Plane {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
getIntersection(Pn1, Pn2, L) {
|
|
50
|
-
|
|
51
50
|
var u = Pn1.n.cross(Pn2.n);
|
|
52
51
|
|
|
53
|
-
var ax =
|
|
54
|
-
var ay =
|
|
55
|
-
var az =
|
|
52
|
+
var ax = u.x >= 0 ? u.x : -u.x;
|
|
53
|
+
var ay = u.y >= 0 ? u.y : -u.y;
|
|
54
|
+
var az = u.z >= 0 ? u.z : -u.z;
|
|
56
55
|
|
|
57
56
|
// test if the two planes are parallel
|
|
58
|
-
if (
|
|
57
|
+
if (ax + ay + az < math.EPSILON5) {
|
|
58
|
+
// Pn1 and Pn2 are near parallel
|
|
59
59
|
// test if disjoint or coincide
|
|
60
60
|
var v = Pn2.p.sub(Pn1.p);
|
|
61
|
-
if (Pn1.n.dot(v) == 0) {
|
|
62
|
-
|
|
61
|
+
if (Pn1.n.dot(v) == 0) {
|
|
62
|
+
// Pn2.V0 lies in Pn1
|
|
63
|
+
return 1; // Pn1 and Pn2 coincide
|
|
63
64
|
} else {
|
|
64
|
-
return 0;
|
|
65
|
+
return 0; // Pn1 and Pn2 are disjoint
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
// Pn1 and Pn2 intersect in a line
|
|
69
70
|
// first determine max abs coordinate of cross product
|
|
70
|
-
var maxc;
|
|
71
|
+
var maxc; // max coordinate
|
|
71
72
|
if (ax > ay) {
|
|
72
73
|
if (ax > az) {
|
|
73
74
|
maxc = 1;
|
|
@@ -86,9 +87,9 @@ class Plane {
|
|
|
86
87
|
// zero the max coord, and solve for the other two
|
|
87
88
|
var iP = new Vec3(); // intersect point
|
|
88
89
|
|
|
89
|
-
var d1, d2;
|
|
90
|
-
d1 = -Pn1.n.dot(Pn1.p);
|
|
91
|
-
d2 = -Pn2.n.dot(Pn2.p);
|
|
90
|
+
var d1, d2; // the constants in the 2 plane equations
|
|
91
|
+
d1 = -Pn1.n.dot(Pn1.p); // note: could be pre-stored with plane
|
|
92
|
+
d2 = -Pn2.n.dot(Pn2.p); // ditto
|
|
92
93
|
|
|
93
94
|
// select max coordinate
|
|
94
95
|
if (maxc === 1) {
|
|
@@ -113,4 +114,4 @@ class Plane {
|
|
|
113
114
|
}
|
|
114
115
|
}
|
|
115
116
|
|
|
116
|
-
export { Plane };
|
|
117
|
+
export { Plane };
|
package/src/og/math/Ray.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* @module og/math/Ray
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
"use strict";
|
|
6
6
|
|
|
7
|
-
import * as math from
|
|
8
|
-
import { Vec3 } from
|
|
7
|
+
import * as math from "../math.js";
|
|
8
|
+
import { Vec3 } from "./Vec3.js";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Represents a ray that extends infinitely from the provided origin in the provided direction.
|
|
@@ -15,7 +15,6 @@ import { Vec3 } from './Vec3.js';
|
|
|
15
15
|
*/
|
|
16
16
|
export class Ray {
|
|
17
17
|
constructor(origin, direction) {
|
|
18
|
-
|
|
19
18
|
/**
|
|
20
19
|
* The origin of the ray.
|
|
21
20
|
* @public
|
|
@@ -32,14 +31,22 @@ export class Ray {
|
|
|
32
31
|
}
|
|
33
32
|
|
|
34
33
|
/** @const */
|
|
35
|
-
static get OUTSIDE() {
|
|
34
|
+
static get OUTSIDE() {
|
|
35
|
+
return 0;
|
|
36
|
+
}
|
|
36
37
|
|
|
37
38
|
/** @const */
|
|
38
|
-
static get INSIDE() {
|
|
39
|
+
static get INSIDE() {
|
|
40
|
+
return 1;
|
|
41
|
+
}
|
|
39
42
|
/** @const */
|
|
40
|
-
static get INPLANE() {
|
|
43
|
+
static get INPLANE() {
|
|
44
|
+
return 2;
|
|
45
|
+
}
|
|
41
46
|
/** @const */
|
|
42
|
-
static get AWAY() {
|
|
47
|
+
static get AWAY() {
|
|
48
|
+
return 3;
|
|
49
|
+
}
|
|
43
50
|
|
|
44
51
|
/**
|
|
45
52
|
* Sets a ray parameters.
|
|
@@ -71,7 +78,7 @@ export class Ray {
|
|
|
71
78
|
* @param {Vec3} v1 - Second triangle corner coordinate.
|
|
72
79
|
* @param {Vec3} v2 - Third triangle corner coordinate.
|
|
73
80
|
* @param {Vec3} res - Hit point object pointer that stores hit result.
|
|
74
|
-
* @returns {number} - Hit code, could 0 - og.Ray.OUTSIDE, 1 - og.Ray.INSIDE,
|
|
81
|
+
* @returns {number} - Hit code, could 0 - og.Ray.OUTSIDE, 1 - og.Ray.INSIDE,
|
|
75
82
|
* 2 - og.Ray.INPLANE and 3 - og.Ray.AWAY(ray goes away from triangle).
|
|
76
83
|
*/
|
|
77
84
|
hitTriangle(v0, v1, v2, res, normal) {
|
|
@@ -120,7 +127,7 @@ export class Ray {
|
|
|
120
127
|
}
|
|
121
128
|
|
|
122
129
|
var t = (uv * wu - uu * wv) / D;
|
|
123
|
-
if (t < 0.0 ||
|
|
130
|
+
if (t < 0.0 || s + t > 1.0) {
|
|
124
131
|
return Ray.OUTSIDE;
|
|
125
132
|
}
|
|
126
133
|
|
|
@@ -218,7 +225,6 @@ export class Ray {
|
|
|
218
225
|
// TODO
|
|
219
226
|
//
|
|
220
227
|
}
|
|
221
|
-
|
|
222
228
|
}
|
|
223
229
|
|
|
224
230
|
/**
|
|
@@ -231,4 +237,3 @@ export class Ray {
|
|
|
231
237
|
export function ray(origin, direction) {
|
|
232
238
|
return new Ray(origin, direction);
|
|
233
239
|
}
|
|
234
|
-
|
package/src/og/math/Vec2.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* @module og/math/Vec2
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
"use strict";
|
|
6
6
|
|
|
7
|
-
import { Vec3 } from
|
|
7
|
+
import { Vec3 } from "./Vec3.js";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Class represents a 3d vector.
|
|
@@ -13,9 +13,7 @@ import { Vec3 } from './Vec3.js';
|
|
|
13
13
|
* @param {number} [y] - Second value.
|
|
14
14
|
*/
|
|
15
15
|
export class Vec2 {
|
|
16
|
-
|
|
17
16
|
constructor(x, y) {
|
|
18
|
-
|
|
19
17
|
/**
|
|
20
18
|
* @public
|
|
21
19
|
* @type {number}
|
|
@@ -29,15 +27,25 @@ export class Vec2 {
|
|
|
29
27
|
this.y = y || 0.0;
|
|
30
28
|
}
|
|
31
29
|
/** @const */
|
|
32
|
-
static get UP() {
|
|
30
|
+
static get UP() {
|
|
31
|
+
return new Vec2(0, 1);
|
|
32
|
+
}
|
|
33
33
|
/** @const */
|
|
34
|
-
static get DOWN() {
|
|
34
|
+
static get DOWN() {
|
|
35
|
+
return new Vec2(0, -1);
|
|
36
|
+
}
|
|
35
37
|
/** @const */
|
|
36
|
-
static get RIGHT() {
|
|
38
|
+
static get RIGHT() {
|
|
39
|
+
return new Vec2(1, 0);
|
|
40
|
+
}
|
|
37
41
|
/** @const */
|
|
38
|
-
static get LEFT() {
|
|
42
|
+
static get LEFT() {
|
|
43
|
+
return new Vec2(-1, 0);
|
|
44
|
+
}
|
|
39
45
|
/** @const */
|
|
40
|
-
static get ZERO() {
|
|
46
|
+
static get ZERO() {
|
|
47
|
+
return new Vec2();
|
|
48
|
+
}
|
|
41
49
|
|
|
42
50
|
/**
|
|
43
51
|
* Returns summary vector.
|
|
@@ -462,15 +470,17 @@ export class Vec2 {
|
|
|
462
470
|
return res;
|
|
463
471
|
}
|
|
464
472
|
|
|
465
|
-
static get LERP_DELTA() {
|
|
473
|
+
static get LERP_DELTA() {
|
|
474
|
+
return 1e-6;
|
|
475
|
+
}
|
|
466
476
|
|
|
467
477
|
/**
|
|
468
478
|
* Spherically interpolates between two vectors.
|
|
469
|
-
* Interpolates between current and v2 vector by amount t. The difference between this and linear interpolation (aka, "lerp") is that
|
|
470
|
-
* the vectors are treated as directions rather than points in space. The direction of the returned vector is interpolated
|
|
479
|
+
* Interpolates between current and v2 vector by amount t. The difference between this and linear interpolation (aka, "lerp") is that
|
|
480
|
+
* the vectors are treated as directions rather than points in space. The direction of the returned vector is interpolated
|
|
471
481
|
* by the angle and its magnitude is interpolated between the magnitudes of from and to.
|
|
472
482
|
* @public
|
|
473
|
-
* @param {math.Vec2} v2 -
|
|
483
|
+
* @param {math.Vec2} v2 -
|
|
474
484
|
* @param {number} t - The parameter t is clamped to the range [0, 1].
|
|
475
485
|
* @returns {math.Vec2}
|
|
476
486
|
*/
|
|
@@ -488,7 +498,7 @@ export class Vec2 {
|
|
|
488
498
|
var omega, sinom, scale0, scale1;
|
|
489
499
|
var cosom = this.dot(v2);
|
|
490
500
|
|
|
491
|
-
if (
|
|
501
|
+
if (1.0 - cosom > Vec2.LERP_DELTA) {
|
|
492
502
|
omega = Math.acos(cosom);
|
|
493
503
|
sinom = Math.sin(omega);
|
|
494
504
|
scale0 = Math.sin((1.0 - t) * omega) / sinom;
|
package/src/og/math/Vec3.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* @module og/math/Vec3
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
"use strict";
|
|
6
6
|
|
|
7
|
-
import { Vec4 } from
|
|
8
|
-
import { Quat } from
|
|
7
|
+
import { Vec4 } from "./Vec4.js";
|
|
8
|
+
import { Quat } from "./Quat.js";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Class represents a 3d vector.
|
|
@@ -15,9 +15,7 @@ import { Quat } from './Quat.js';
|
|
|
15
15
|
* @param {number} [z] - Third value.
|
|
16
16
|
*/
|
|
17
17
|
export class Vec3 {
|
|
18
|
-
|
|
19
18
|
constructor(x, y, z) {
|
|
20
|
-
|
|
21
19
|
/**
|
|
22
20
|
* @public
|
|
23
21
|
* @type {number}
|
|
@@ -38,25 +36,45 @@ export class Vec3 {
|
|
|
38
36
|
}
|
|
39
37
|
|
|
40
38
|
/** @const */
|
|
41
|
-
static get UP() {
|
|
39
|
+
static get UP() {
|
|
40
|
+
return new Vec3(0, 1, 0);
|
|
41
|
+
}
|
|
42
42
|
/** @const */
|
|
43
|
-
static get DOWN() {
|
|
43
|
+
static get DOWN() {
|
|
44
|
+
return new Vec3(0, -1, 0);
|
|
45
|
+
}
|
|
44
46
|
/** @const */
|
|
45
|
-
static get RIGHT() {
|
|
47
|
+
static get RIGHT() {
|
|
48
|
+
return new Vec3(1, 0, 0);
|
|
49
|
+
}
|
|
46
50
|
/** @const */
|
|
47
|
-
static get LEFT() {
|
|
51
|
+
static get LEFT() {
|
|
52
|
+
return new Vec3(-1, 0, 0);
|
|
53
|
+
}
|
|
48
54
|
/** @const */
|
|
49
|
-
static get FORWARD() {
|
|
55
|
+
static get FORWARD() {
|
|
56
|
+
return new Vec3(0, 0, -1);
|
|
57
|
+
}
|
|
50
58
|
/** @const */
|
|
51
|
-
static get BACKWARD() {
|
|
59
|
+
static get BACKWARD() {
|
|
60
|
+
return new Vec3(0, 0, 1);
|
|
61
|
+
}
|
|
52
62
|
/** @const */
|
|
53
|
-
static get ZERO() {
|
|
63
|
+
static get ZERO() {
|
|
64
|
+
return new Vec3();
|
|
65
|
+
}
|
|
54
66
|
/** @const */
|
|
55
|
-
static get UNIT_X() {
|
|
67
|
+
static get UNIT_X() {
|
|
68
|
+
return new Vec3(1, 0, 0);
|
|
69
|
+
}
|
|
56
70
|
/** @const */
|
|
57
|
-
static get UNIT_Y() {
|
|
71
|
+
static get UNIT_Y() {
|
|
72
|
+
return new Vec3(0, 1, 0);
|
|
73
|
+
}
|
|
58
74
|
/** @const */
|
|
59
|
-
static get UNIT_Z() {
|
|
75
|
+
static get UNIT_Z() {
|
|
76
|
+
return new Vec3(0, 0, 1);
|
|
77
|
+
}
|
|
60
78
|
|
|
61
79
|
/**
|
|
62
80
|
* Separate 63 bit Vec3 to two Vec3 32 bit float values.
|
|
@@ -67,8 +85,9 @@ export class Vec3 {
|
|
|
67
85
|
* @returns {Array.<number>} Encoded array. (exactly 2 entries)
|
|
68
86
|
*/
|
|
69
87
|
static doubleToTwoFloats(v, high, low) {
|
|
70
|
-
|
|
71
|
-
|
|
88
|
+
let x = v.x,
|
|
89
|
+
y = v.y,
|
|
90
|
+
z = v.z;
|
|
72
91
|
|
|
73
92
|
if (x >= 0.0) {
|
|
74
93
|
let doubleHigh = Math.floor(x / 65536.0) * 65536.0;
|
|
@@ -110,8 +129,9 @@ export class Vec3 {
|
|
|
110
129
|
* @returns {Array.<number>} Encoded array. (exactly 2 entries)
|
|
111
130
|
*/
|
|
112
131
|
static doubleToTwoFloat32Array(v, high, low) {
|
|
113
|
-
|
|
114
|
-
|
|
132
|
+
let x = v.x,
|
|
133
|
+
y = v.y,
|
|
134
|
+
z = v.z;
|
|
115
135
|
|
|
116
136
|
if (x >= 0.0) {
|
|
117
137
|
let doubleHigh = Math.floor(x / 65536.0) * 65536.0;
|
|
@@ -245,7 +265,7 @@ export class Vec3 {
|
|
|
245
265
|
* @static
|
|
246
266
|
* @param {Vec3} b - Vector to project.
|
|
247
267
|
* @param {Vec3} n - Plane normal.
|
|
248
|
-
|
|
268
|
+
* @param {Vec3} [def] - Default value for non existed result.
|
|
249
269
|
* @returns {Vec3} -
|
|
250
270
|
*/
|
|
251
271
|
static proj_b_to_plane(b, n, def) {
|
|
@@ -750,7 +770,11 @@ export class Vec3 {
|
|
|
750
770
|
* @returns {Vec3} -
|
|
751
771
|
*/
|
|
752
772
|
lerp(v2, l) {
|
|
753
|
-
return new Vec3(
|
|
773
|
+
return new Vec3(
|
|
774
|
+
this.x + (v2.x - this.x) * l,
|
|
775
|
+
this.y + (v2.y - this.y) * l,
|
|
776
|
+
this.z + (v2.z - this.z) * l
|
|
777
|
+
);
|
|
754
778
|
}
|
|
755
779
|
|
|
756
780
|
/**
|
|
@@ -762,18 +786,24 @@ export class Vec3 {
|
|
|
762
786
|
*/
|
|
763
787
|
smerp(v2, t) {
|
|
764
788
|
var one_d = 1 - t;
|
|
765
|
-
return new Vec3(
|
|
789
|
+
return new Vec3(
|
|
790
|
+
this.x * t + v2.x * one_d,
|
|
791
|
+
this.y * t + v2.y * one_d,
|
|
792
|
+
this.z * t + v2.z * one_d
|
|
793
|
+
);
|
|
766
794
|
}
|
|
767
795
|
|
|
768
|
-
static get LERP_DELTA() {
|
|
796
|
+
static get LERP_DELTA() {
|
|
797
|
+
return 1e-6;
|
|
798
|
+
}
|
|
769
799
|
|
|
770
800
|
/**
|
|
771
801
|
* Spherically interpolates between two vectors.
|
|
772
|
-
* Interpolates between current and v2 vector by amount t. The difference between this and linear interpolation (aka, "lerp") is that
|
|
773
|
-
* the vectors are treated as directions rather than points in space. The direction of the returned vector is interpolated
|
|
802
|
+
* Interpolates between current and v2 vector by amount t. The difference between this and linear interpolation (aka, "lerp") is that
|
|
803
|
+
* the vectors are treated as directions rather than points in space. The direction of the returned vector is interpolated
|
|
774
804
|
* by the angle and its magnitude is interpolated between the magnitudes of from and to.
|
|
775
805
|
* @public
|
|
776
|
-
* @param {Vec3} v2 -
|
|
806
|
+
* @param {Vec3} v2 -
|
|
777
807
|
* @param {number} t - The parameter t is clamped to the range [0, 1].
|
|
778
808
|
* @returns {Vec3} -
|
|
779
809
|
*/
|
|
@@ -791,7 +821,7 @@ export class Vec3 {
|
|
|
791
821
|
var omega, sinom, scale0, scale1;
|
|
792
822
|
var cosom = this.dot(v2);
|
|
793
823
|
|
|
794
|
-
if (
|
|
824
|
+
if (1.0 - cosom > Vec3.LERP_DELTA) {
|
|
795
825
|
omega = Math.acos(cosom);
|
|
796
826
|
sinom = Math.sin(omega);
|
|
797
827
|
scale0 = Math.sin((1.0 - t) * omega) / sinom;
|
|
@@ -825,14 +855,15 @@ export class Vec3 {
|
|
|
825
855
|
return Quat.IDENTITY.clone();
|
|
826
856
|
}
|
|
827
857
|
|
|
828
|
-
if (d <
|
|
858
|
+
if (d < 1e-6 - 1.0) {
|
|
829
859
|
if (!fallbackAxis.isEqual(Vec3.ZERO)) {
|
|
830
860
|
// rotate 180 degrees about the fallback axis
|
|
831
861
|
return Quat.axisAngleToQuat(Math.PI, fallbackAxis);
|
|
832
862
|
} else {
|
|
833
863
|
// Generate an axis
|
|
834
864
|
let axis = Vec3.UNIT_X.cross(v0);
|
|
835
|
-
if (axis.isZero()) {
|
|
865
|
+
if (axis.isZero()) {
|
|
866
|
+
// pick another if colinear
|
|
836
867
|
axis = Vec3.UNIT_Y.cross(v0);
|
|
837
868
|
}
|
|
838
869
|
axis.normalize();
|
|
@@ -862,4 +893,3 @@ export class Vec3 {
|
|
|
862
893
|
export function vec3(x, y, z) {
|
|
863
894
|
return new Vec3(x, y, z);
|
|
864
895
|
}
|
|
865
|
-
|
package/src/og/math/coder.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* @module og/math/coder
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
"use strict";
|
|
6
6
|
|
|
7
|
-
import * as math from
|
|
8
|
-
import { Vec4 } from
|
|
7
|
+
import * as math from "../math.js";
|
|
8
|
+
import { Vec4 } from "./Vec4.js";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Encode 32 bit float value to the RGBA vector.
|
|
@@ -14,7 +14,7 @@ import { Vec4 } from './Vec4.js';
|
|
|
14
14
|
* @returns {math.Vec4} - RGBA vector value.
|
|
15
15
|
*/
|
|
16
16
|
export function encodeFloatToRGBA(v) {
|
|
17
|
-
var enc = new Vec4(1.0 * v % 1, 255.0 * v % 1, 65025.0 * v % 1, 160581375.0 * v % 1);
|
|
17
|
+
var enc = new Vec4((1.0 * v) % 1, (255.0 * v) % 1, (65025.0 * v) % 1, (160581375.0 * v) % 1);
|
|
18
18
|
var yzww = new Vec4(enc.y / 255, enc.z / 255, enc.w / 255, 0);
|
|
19
19
|
return enc.subA(yzww);
|
|
20
20
|
}
|
|
@@ -28,7 +28,7 @@ export function encodeFloatToRGBA(v) {
|
|
|
28
28
|
export function decodeFloatFromRGBA(rgba) {
|
|
29
29
|
var s = 1.0 - math.step(128.0, rgba.x) * 2.0;
|
|
30
30
|
var e = 2.0 * math.mod(rgba.x, 128.0) + math.step(128.0, rgba.y) - 127.0;
|
|
31
|
-
var m = math.mod(rgba.y, 128.0) * 65536.0 + rgba.z * 256.0 + rgba.w + 8388608.
|
|
31
|
+
var m = math.mod(rgba.y, 128.0) * 65536.0 + rgba.z * 256.0 + rgba.w + 8388608.0;
|
|
32
32
|
return s * math.exp2(e) * (m * 1.1920928955078125e-7);
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -41,7 +41,7 @@ export function decodeFloatFromRGBA(rgba) {
|
|
|
41
41
|
export function decodeFloatFromRGBAArr(arr, use32) {
|
|
42
42
|
var s = 1.0 - math.step(128.0, arr[0]) * 2.0;
|
|
43
43
|
var e = 2.0 * math.mod(arr[0], 128.0) + math.step(128.0, arr[1]) - 127.0;
|
|
44
|
-
var m = math.mod(arr[1], 128.0) * 65536.0 + arr[2] * 256.0 + (use32 ? arr[3] : 0.0) + 8388608.
|
|
44
|
+
var m = math.mod(arr[1], 128.0) * 65536.0 + arr[2] * 256.0 + (use32 ? arr[3] : 0.0) + 8388608.0;
|
|
45
45
|
return s * math.exp2(e) * (m * 1.1920928955078125e-7);
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -101,4 +101,4 @@ export function doubleToTwoFloatsV2(value, highLowVec) {
|
|
|
101
101
|
highLowVec.y = Math.fround(value + doubleHigh);
|
|
102
102
|
}
|
|
103
103
|
return highLowVec;
|
|
104
|
-
}
|
|
104
|
+
}
|
package/src/og/proj/EPSG3857.js
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* @module og/proj/EPSG3857
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
"use strict";
|
|
6
6
|
|
|
7
|
-
import { Units, Proj } from
|
|
7
|
+
import { Units, Proj } from "./Proj.js";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* EPSG:3857 projection object.
|
|
11
11
|
* @type {Proj}
|
|
12
12
|
*/
|
|
13
|
-
export const EPSG3857 = new Proj({ code: "epsg:3857", units: Units.METERS });
|
|
13
|
+
export const EPSG3857 = new Proj({ code: "epsg:3857", units: Units.METERS });
|
package/src/og/proj/EPSG4326.js
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* @module og/proj/EPSG4326
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
"use strict";
|
|
6
6
|
|
|
7
|
-
import { Units, Proj } from
|
|
7
|
+
import { Units, Proj } from "./Proj.js";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* EPSG:4326 projection object.
|
|
11
11
|
* @type {Proj}
|
|
12
12
|
*/
|
|
13
|
-
export const EPSG4326 = new Proj({ code: "epsg:4326", units: Units.DEGREES });
|
|
13
|
+
export const EPSG4326 = new Proj({ code: "epsg:4326", units: Units.DEGREES });
|
package/src/og/proj/Proj.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @module og/proj/Proj
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
"use strict";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Projection units: 'degrees', 'ft', 'm' or 'km'.
|
|
@@ -28,9 +28,7 @@ METERS_PER_UNIT[Units.KILOMETERS] = 1000;
|
|
|
28
28
|
|
|
29
29
|
let _counter = 0;
|
|
30
30
|
class Proj {
|
|
31
|
-
|
|
32
31
|
constructor(options) {
|
|
33
|
-
|
|
34
32
|
/**
|
|
35
33
|
* @public
|
|
36
34
|
* @type {string}
|
|
@@ -62,4 +60,4 @@ class Proj {
|
|
|
62
60
|
}
|
|
63
61
|
}
|
|
64
62
|
|
|
65
|
-
export { Proj };
|
|
63
|
+
export { Proj };
|
package/src/og/quadTree/Node.js
CHANGED
|
@@ -64,7 +64,6 @@ let BOUNDS = {
|
|
|
64
64
|
* @param {Extent} extent - Planet segment extent.
|
|
65
65
|
*/
|
|
66
66
|
class Node {
|
|
67
|
-
|
|
68
67
|
constructor(SegmentPrototype, planet, partId, parent, id, tileZoom, extent) {
|
|
69
68
|
this.SegmentPrototype = SegmentPrototype;
|
|
70
69
|
this.planet = planet;
|
|
@@ -279,12 +278,12 @@ class Node {
|
|
|
279
278
|
}
|
|
280
279
|
}
|
|
281
280
|
|
|
282
|
-
|
|
283
|
-
|
|
281
|
+
if (this.inFrustum || this._cameraInside || seg.tileZoom < 3) {
|
|
282
|
+
let h = cam._lonLat.height;
|
|
284
283
|
|
|
285
284
|
let altVis =
|
|
286
285
|
cam.eye.distance(seg.bsphere.center) - seg.bsphere.radius <
|
|
287
|
-
|
|
286
|
+
VISIBLE_DISTANCE * Math.sqrt(h) ||
|
|
288
287
|
(seg.tileZoom < 4 && !seg.terrainReady) ||
|
|
289
288
|
seg.tileZoom < 2;
|
|
290
289
|
|
|
@@ -295,14 +294,26 @@ class Node {
|
|
|
295
294
|
if (seg.tileZoom < 2 && seg.normalMapReady) {
|
|
296
295
|
this.traverseNodes(cam, maxZoom, terrainReadySegment, stopLoading);
|
|
297
296
|
} else if ((!maxZoom && seg.acceptForRendering(cam)) || seg.tileZoom === maxZoom) {
|
|
298
|
-
this.prepareForRendering(
|
|
297
|
+
this.prepareForRendering(
|
|
298
|
+
cam,
|
|
299
|
+
altVis,
|
|
300
|
+
this.inFrustum,
|
|
301
|
+
terrainReadySegment,
|
|
302
|
+
stopLoading
|
|
303
|
+
);
|
|
299
304
|
} else if (seg.tileZoom < planet.terrain._maxNodeZoom && seg.terrainReady) {
|
|
300
305
|
// Deleting terrainReady here, you have to remove
|
|
301
306
|
// this.appliedTerrainNodeId !== pn.nodeId in whileTerrainLoading,
|
|
302
307
|
// also have to fix createBoundsByParent(*)
|
|
303
308
|
this.traverseNodes(cam, maxZoom, seg, stopLoading);
|
|
304
309
|
} else {
|
|
305
|
-
this.prepareForRendering(
|
|
310
|
+
this.prepareForRendering(
|
|
311
|
+
cam,
|
|
312
|
+
altVis,
|
|
313
|
+
this.inFrustum,
|
|
314
|
+
terrainReadySegment,
|
|
315
|
+
stopLoading
|
|
316
|
+
);
|
|
306
317
|
}
|
|
307
318
|
} else {
|
|
308
319
|
this.state = NOTRENDERING;
|
|
@@ -322,13 +333,7 @@ class Node {
|
|
|
322
333
|
n[3].renderTree(cam, maxZoom, terrainReadySegment, stopLoading);
|
|
323
334
|
}
|
|
324
335
|
|
|
325
|
-
prepareForRendering(
|
|
326
|
-
cam,
|
|
327
|
-
altVis,
|
|
328
|
-
inFrustum,
|
|
329
|
-
terrainReadySegment,
|
|
330
|
-
stopLoading
|
|
331
|
-
) {
|
|
336
|
+
prepareForRendering(cam, altVis, inFrustum, terrainReadySegment, stopLoading) {
|
|
332
337
|
let seg = this.segment;
|
|
333
338
|
|
|
334
339
|
if (cam._lonLat.height < VISIBLE_HEIGHT) {
|
|
@@ -376,7 +381,7 @@ class Node {
|
|
|
376
381
|
}
|
|
377
382
|
|
|
378
383
|
// Create normal map texture
|
|
379
|
-
if (seg.planet.lightEnabled && !seg.normalMapReady && !seg.parentNormalMapReady) {
|
|
384
|
+
if (seg.planet.lightEnabled && !seg.normalMapReady /* && !seg.parentNormalMapReady*/) {
|
|
380
385
|
this.whileNormalMapCreating();
|
|
381
386
|
}
|
|
382
387
|
|
|
@@ -769,8 +774,16 @@ class Node {
|
|
|
769
774
|
let v_lt = new Vec3(bigOne[0], bigOne[1], bigOne[2]),
|
|
770
775
|
v_rb = new Vec3(bigOne[9], bigOne[10], bigOne[11]);
|
|
771
776
|
|
|
772
|
-
let vn = new Vec3(
|
|
773
|
-
|
|
777
|
+
let vn = new Vec3(
|
|
778
|
+
bigOne[3] - bigOne[0],
|
|
779
|
+
bigOne[4] - bigOne[1],
|
|
780
|
+
bigOne[5] - bigOne[2]
|
|
781
|
+
),
|
|
782
|
+
vw = new Vec3(
|
|
783
|
+
bigOne[6] - bigOne[0],
|
|
784
|
+
bigOne[7] - bigOne[1],
|
|
785
|
+
bigOne[8] - bigOne[2]
|
|
786
|
+
),
|
|
774
787
|
ve = new Vec3(
|
|
775
788
|
bigOne[3] - bigOne[9],
|
|
776
789
|
bigOne[4] - bigOne[10],
|
|
@@ -983,7 +996,8 @@ class Node {
|
|
|
983
996
|
offset = 0;
|
|
984
997
|
|
|
985
998
|
while (pNode.segment.tileZoom > neighbourZoom) {
|
|
986
|
-
offset +=
|
|
999
|
+
offset +=
|
|
1000
|
+
PARTOFFSET[pNode.partId][side] / (1 << (pNode.segment.tileZoom - neighbourZoom));
|
|
987
1001
|
pNode = pNode.parentNode;
|
|
988
1002
|
}
|
|
989
1003
|
|