@openglobus/og 0.16.3 → 0.17.0
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 -1
- package/css/og.css +24 -2
- 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 +1 -1
- package/src/og/Clock.js +1 -5
- package/src/og/Events.js +0 -4
- package/src/og/Extent.js +5 -9
- package/src/og/Globe.js +92 -55
- package/src/og/ImageCanvas.js +12 -5
- package/src/og/Lock.js +44 -48
- package/src/og/LonLat.js +0 -4
- package/src/og/Object3d.js +1 -1
- package/src/og/Stack.js +49 -53
- package/src/og/astro/earth.js +112 -116
- package/src/og/astro/jd.js +514 -518
- package/src/og/astro/orbit.js +119 -123
- package/src/og/astro/rotation.js +36 -40
- package/src/og/bv/Box.js +77 -81
- package/src/og/bv/Sphere.js +57 -61
- package/src/og/camera/Camera.js +20 -7
- package/src/og/camera/PlanetCamera.js +8 -15
- package/src/og/control/Atmosphere.js +0 -4
- package/src/og/control/Control.js +9 -8
- package/src/og/control/DebugInfo.js +0 -4
- package/src/og/control/DrawingSwitcher.js +117 -0
- package/src/og/control/EarthCoordinates.js +214 -214
- package/src/og/control/GeoImageDragControl.js +0 -4
- package/src/og/control/KeyboardNavigation.js +0 -4
- package/src/og/control/LayerAnimation.js +0 -4
- package/src/og/control/LayerSwitcher.js +2 -4
- package/src/og/control/Lighting.js +11 -15
- package/src/og/control/MouseNavigation.js +0 -4
- package/src/og/control/MouseWheelZoomControl.js +0 -4
- package/src/og/control/RulerSwitcher.js +0 -4
- package/src/og/control/ScaleControl.js +2 -6
- package/src/og/control/ShowFps.js +40 -44
- package/src/og/control/SimpleNavigation.js +10 -10
- package/src/og/control/SimpleSkyBackground.js +0 -4
- package/src/og/control/Sun.js +0 -4
- package/src/og/control/ToggleWireframe.js +35 -39
- package/src/og/control/ZoomControl.js +0 -4
- package/src/og/control/drawing/DrawingControl.js +51 -0
- package/src/og/control/drawing/LineStringDrawingScene.js +203 -0
- package/src/og/control/drawing/PolygonDrawingScene.js +785 -0
- package/src/og/control/elevationProfile/ElevationProfile.js +275 -0
- package/src/og/control/index.js +5 -1
- package/src/og/control/ruler/Ruler.js +0 -4
- package/src/og/control/ruler/RulerScene.js +3 -2
- package/src/og/control/selection/Selection.js +0 -4
- package/src/og/control/selection/SelectionScene.js +2 -4
- package/src/og/control/timeline/TimelineControl.js +4 -4
- package/src/og/control/timeline/TimelineModel.js +2 -2
- package/src/og/control/timeline/TimelineView.js +1 -0
- package/src/og/control/visibleExtent/Segment.js +5 -5
- package/src/og/control/visibleExtent/drawnode.js +0 -4
- package/src/og/ellipsoid/Ellipsoid.js +205 -275
- package/src/og/ellipsoid/wgs84.js +0 -4
- package/src/og/entity/BaseBillboard.js +375 -379
- package/src/og/entity/Billboard.js +0 -4
- package/src/og/entity/BillboardHandler.js +0 -4
- package/src/og/entity/Entity.js +22 -22
- package/src/og/entity/EntityCollection.js +7 -11
- package/src/og/entity/GeoObject.js +0 -4
- package/src/og/entity/GeoObjectHandler.js +0 -4
- package/src/og/entity/Geometry.js +5 -4
- package/src/og/entity/GeometryHandler.js +3 -4
- package/src/og/entity/Label.js +0 -4
- package/src/og/entity/LabelHandler.js +0 -4
- package/src/og/entity/PointCloud.js +0 -4
- package/src/og/entity/PointCloudHandler.js +122 -126
- package/src/og/entity/Polyline.js +4 -6
- package/src/og/entity/PolylineHandler.js +104 -108
- package/src/og/entity/Ray.js +29 -29
- package/src/og/entity/Strip.js +1 -1
- package/src/og/index.js +3 -1
- package/src/og/input/KeyboardHandler.js +128 -132
- package/src/og/input/MouseHandler.js +94 -98
- package/src/og/input/TouchHandler.js +59 -63
- package/src/og/input/input.js +44 -48
- package/src/og/layer/BaseGeoImage.js +5 -8
- package/src/og/layer/CanvasTiles.js +0 -4
- package/src/og/layer/GeoImage.js +0 -4
- package/src/og/layer/GeoTexture2d.js +0 -4
- package/src/og/layer/GeoVideo.js +0 -4
- package/src/og/layer/KML.js +1 -0
- package/src/og/layer/Layer.js +22 -26
- package/src/og/layer/Material.js +0 -4
- package/src/og/layer/Vector.js +23 -20
- package/src/og/layer/WMS.js +182 -186
- package/src/og/layer/XYZ.js +0 -4
- package/src/og/light/LightSource.js +0 -4
- package/src/og/math/Line2.js +28 -32
- package/src/og/math/Mat3.js +152 -156
- package/src/og/math/Ray.js +0 -4
- package/src/og/math/Vec2.js +0 -4
- package/src/og/math/Vec3.js +0 -4
- package/src/og/math/Vec4.js +0 -4
- package/src/og/math/coder.js +104 -104
- package/src/og/math.js +39 -7
- package/src/og/proj/EPSG3857.js +13 -13
- package/src/og/proj/Proj.js +59 -63
- package/src/og/quadTree/EPSG4326QuadTreeStrategy.js +1 -0
- package/src/og/quadTree/EarthQuadTreeStrategy.js +1 -0
- package/src/og/quadTree/EntityCollectionNode.js +12 -16
- package/src/og/quadTree/MarsQuadTreeStrategy.js +1 -0
- package/src/og/quadTree/QuadTreeStrategy.js +1 -0
- package/src/og/quadTree/Wgs84QuadTreeStrategy.js +1 -0
- package/src/og/renderer/Renderer.js +109 -22
- package/src/og/renderer/RendererEvents.js +0 -4
- package/src/og/scene/Axes.js +74 -78
- package/src/og/scene/BaseNode.js +0 -4
- package/src/og/scene/Planet.js +114 -112
- package/src/og/scene/RenderNode.js +11 -3
- package/src/og/scene/SkyBox.js +104 -108
- package/src/og/segment/Segment.js +8 -4
- package/src/og/segment/SegmentLonLat.js +2 -6
- package/src/og/segment/segmentHelper.js +229 -225
- package/src/og/shaders/billboard.js +0 -4
- package/src/og/shaders/drawnode.js +5 -9
- package/src/og/shaders/geoObject.js +0 -4
- package/src/og/shaders/label.js +0 -4
- package/src/og/shaders/pickingMask.js +0 -4
- package/src/og/shaders/pointCloud.js +0 -4
- package/src/og/shaders/polyline.js +0 -4
- package/src/og/shaders/ray.js +0 -4
- package/src/og/shaders/skybox.js +0 -4
- package/src/og/terrain/EmptyTerrain.js +0 -4
- package/src/og/utils/FontAtlas.js +0 -4
- package/src/og/utils/GeoImageCreator.js +1 -2
- package/src/og/utils/NormalMapCreator.js +8 -9
- package/src/og/utils/VectorTileCreator.js +3 -9
- package/src/og/utils/shared.js +20 -1
- package/src/og/webgl/Framebuffer.js +0 -4
- package/src/og/webgl/Handler.js +45 -19
- package/src/og/webgl/Multisample.js +0 -4
- package/src/og/webgl/Program.js +0 -4
- package/src/og/webgl/ProgramController.js +2 -2
- package/types/Clock.d.ts +1 -1
- package/types/Extent.d.ts +5 -5
- package/types/Globe.d.ts +15 -1
- package/types/ImageCanvas.d.ts +5 -0
- package/types/bv/Box.d.ts +1 -1
- package/types/bv/Sphere.d.ts +3 -3
- package/types/camera/Camera.d.ts +3 -2
- package/types/camera/PlanetCamera.d.ts +4 -4
- package/types/control/DrawingSwitcher.d.ts +13 -0
- package/types/control/EarthCoordinates.d.ts +1 -1
- package/types/control/Lighting.d.ts +8 -8
- package/types/control/drawing/DrawingControl.d.ts +14 -0
- package/types/control/drawing/LineStringDrawingScene.d.ts +5 -0
- package/types/control/drawing/PolygonDrawingScene.d.ts +99 -0
- package/types/control/index.d.ts +3 -1
- package/types/control/ruler/RulerScene.d.ts +0 -1
- package/types/control/selection/SelectionScene.d.ts +0 -1
- package/types/ellipsoid/Ellipsoid.d.ts +50 -63
- package/types/entity/Entity.d.ts +3 -2
- package/types/entity/Geometry.d.ts +5 -0
- package/types/entity/Polyline.d.ts +1 -1
- package/types/entity/Ray.d.ts +1 -0
- package/types/index.d.ts +1 -0
- package/types/layer/BaseGeoImage.d.ts +1 -1
- package/types/layer/CanvasTiles.d.ts +1 -1
- package/types/layer/Layer.d.ts +1 -1
- package/types/layer/Vector.d.ts +1 -0
- package/types/math.d.ts +7 -0
- package/types/renderer/Renderer.d.ts +7 -1
- package/types/scene/Axes.d.ts +0 -1
- package/types/scene/Planet.d.ts +26 -24
- package/types/scene/RenderNode.d.ts +2 -0
- package/types/scene/SkyBox.d.ts +0 -1
- package/types/segment/Segment.d.ts +3 -2
- package/types/segment/SegmentLonLat.d.ts +0 -1
- package/types/utils/GeoImageCreator.d.ts +1 -1
- package/types/utils/NormalMapCreator.d.ts +1 -1
- package/types/utils/VectorTileCreator.d.ts +2 -2
- package/types/utils/shared.d.ts +2 -0
- package/types/webgl/Handler.d.ts +6 -4
package/src/og/math/Mat3.js
CHANGED
|
@@ -1,156 +1,152 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
this._m[
|
|
32
|
-
this._m[
|
|
33
|
-
this._m[
|
|
34
|
-
this._m[
|
|
35
|
-
this._m[
|
|
36
|
-
this
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
res._m[
|
|
73
|
-
res._m[
|
|
74
|
-
res._m[
|
|
75
|
-
res._m[
|
|
76
|
-
res._m[
|
|
77
|
-
res
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
this._m[
|
|
91
|
-
this._m[
|
|
92
|
-
this._m[
|
|
93
|
-
this._m[
|
|
94
|
-
this._m[
|
|
95
|
-
this
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
e
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
b[
|
|
130
|
-
b[
|
|
131
|
-
b[
|
|
132
|
-
b[
|
|
133
|
-
b[
|
|
134
|
-
b[
|
|
135
|
-
b[
|
|
136
|
-
b[
|
|
137
|
-
b[
|
|
138
|
-
b[
|
|
139
|
-
b[
|
|
140
|
-
b[
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
*/
|
|
154
|
-
export function mat3() {
|
|
155
|
-
return new Mat3();
|
|
156
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { Mat4 } from "./Mat4.js";
|
|
4
|
+
import { Vec3 } from "./Vec3.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Class represents a 3x3 matrix.
|
|
8
|
+
* @class
|
|
9
|
+
*/
|
|
10
|
+
export class Mat3 {
|
|
11
|
+
constructor() {
|
|
12
|
+
/**
|
|
13
|
+
* A 3x3 matrix, indexable as a column-major order array.
|
|
14
|
+
* @public
|
|
15
|
+
* @type {Array.<number>}
|
|
16
|
+
*/
|
|
17
|
+
this._m = new Array(9);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Sets column-major order array matrix.
|
|
22
|
+
* @public
|
|
23
|
+
* @param {Array.<number>} m - Matrix array.
|
|
24
|
+
* @returns {Mat3}
|
|
25
|
+
*/
|
|
26
|
+
set(m) {
|
|
27
|
+
this._m[0] = m[0];
|
|
28
|
+
this._m[1] = m[1];
|
|
29
|
+
this._m[2] = m[2];
|
|
30
|
+
this._m[3] = m[3];
|
|
31
|
+
this._m[4] = m[4];
|
|
32
|
+
this._m[5] = m[5];
|
|
33
|
+
this._m[6] = m[6];
|
|
34
|
+
this._m[7] = m[7];
|
|
35
|
+
this._m[8] = m[8];
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Duplicates a Mat3 instance.
|
|
41
|
+
* @public
|
|
42
|
+
* @returns {Mat3}
|
|
43
|
+
*/
|
|
44
|
+
clone() {
|
|
45
|
+
var res = new Mat3();
|
|
46
|
+
res.set(this);
|
|
47
|
+
return res;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Copy matrix.
|
|
52
|
+
* @public
|
|
53
|
+
* @param {Mat3} a - Matrix to copy.
|
|
54
|
+
* @returns {Mat3}
|
|
55
|
+
*/
|
|
56
|
+
copy(a) {
|
|
57
|
+
return this.set(a._m);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Creates trasposed matrix from the current.
|
|
62
|
+
* @public
|
|
63
|
+
* @returns {Mat3}
|
|
64
|
+
*/
|
|
65
|
+
transposeTo() {
|
|
66
|
+
var res = new Mat3();
|
|
67
|
+
var m = this._m;
|
|
68
|
+
res._m[0] = m[0];
|
|
69
|
+
res._m[1] = m[3];
|
|
70
|
+
res._m[2] = m[6];
|
|
71
|
+
res._m[3] = m[1];
|
|
72
|
+
res._m[4] = m[4];
|
|
73
|
+
res._m[5] = m[7];
|
|
74
|
+
res._m[6] = m[2];
|
|
75
|
+
res._m[7] = m[5];
|
|
76
|
+
res._m[8] = m[8];
|
|
77
|
+
return res;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Sets matrix to identity.
|
|
82
|
+
* @public
|
|
83
|
+
* @returns {Mat3}
|
|
84
|
+
*/
|
|
85
|
+
setIdentity() {
|
|
86
|
+
this._m[0] = 1;
|
|
87
|
+
this._m[1] = 0;
|
|
88
|
+
this._m[2] = 0;
|
|
89
|
+
this._m[3] = 0;
|
|
90
|
+
this._m[4] = 1;
|
|
91
|
+
this._m[5] = 0;
|
|
92
|
+
this._m[6] = 0;
|
|
93
|
+
this._m[7] = 0;
|
|
94
|
+
this._m[8] = 1;
|
|
95
|
+
return this;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Multiply to 3d vector.
|
|
100
|
+
* @public
|
|
101
|
+
* @params {Vec3} p - 3d vector.
|
|
102
|
+
* @returns {Vec3}
|
|
103
|
+
*/
|
|
104
|
+
mulVec(p) {
|
|
105
|
+
var d = p.x,
|
|
106
|
+
e = p.y,
|
|
107
|
+
g = p.z;
|
|
108
|
+
var m = this._m;
|
|
109
|
+
return new Vec3(
|
|
110
|
+
m[0] * d + m[3] * e + m[6] * g,
|
|
111
|
+
m[1] * d + m[4] * e + m[7] * g,
|
|
112
|
+
m[2] * d + m[5] * e + m[8] * g
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Converts to 4x4 matrix.
|
|
118
|
+
* @public
|
|
119
|
+
* @returns {Mat4}
|
|
120
|
+
*/
|
|
121
|
+
toMatrix4() {
|
|
122
|
+
var res = new Mat4();
|
|
123
|
+
var b = res._m;
|
|
124
|
+
var a = this._m;
|
|
125
|
+
b[0] = a[0];
|
|
126
|
+
b[1] = a[1];
|
|
127
|
+
b[2] = a[2];
|
|
128
|
+
b[3] = 0;
|
|
129
|
+
b[4] = a[3];
|
|
130
|
+
b[5] = a[4];
|
|
131
|
+
b[6] = a[5];
|
|
132
|
+
b[7] = 0;
|
|
133
|
+
b[8] = a[6];
|
|
134
|
+
b[9] = a[7];
|
|
135
|
+
b[10] = a[8];
|
|
136
|
+
b[11] = 0;
|
|
137
|
+
b[12] = 0;
|
|
138
|
+
b[13] = 0;
|
|
139
|
+
b[14] = 0;
|
|
140
|
+
b[15] = 1;
|
|
141
|
+
return res;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Mat3 factory.
|
|
147
|
+
* @static
|
|
148
|
+
* @return {Mat3}
|
|
149
|
+
*/
|
|
150
|
+
export function mat3() {
|
|
151
|
+
return new Mat3();
|
|
152
|
+
}
|
package/src/og/math/Ray.js
CHANGED
package/src/og/math/Vec2.js
CHANGED
package/src/og/math/Vec3.js
CHANGED
package/src/og/math/Vec4.js
CHANGED
package/src/og/math/coder.js
CHANGED
|
@@ -1,104 +1,104 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module og/math/coder
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
"use strict";
|
|
6
|
-
|
|
7
|
-
import * as math from "../math.js";
|
|
8
|
-
import { Vec4 } from "./Vec4.js";
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Encode 32 bit float value to the RGBA vector.
|
|
12
|
-
* @function
|
|
13
|
-
* @param {number} v - 32 bit float value.
|
|
14
|
-
* @returns {math.Vec4} - RGBA vector value.
|
|
15
|
-
*/
|
|
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);
|
|
18
|
-
var yzww = new Vec4(enc.y / 255, enc.z / 255, enc.w / 255, 0);
|
|
19
|
-
return enc.subA(yzww);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Decode RGBA vector to 32 bit float value.
|
|
24
|
-
* @function
|
|
25
|
-
* @param {Vec4} rgba - RGBA encoded 32 bit float value.
|
|
26
|
-
* @returns {number} - Float value.
|
|
27
|
-
*/
|
|
28
|
-
export function decodeFloatFromRGBA(rgba) {
|
|
29
|
-
var s = 1.0 - math.step(128.0, rgba.x) * 2.0;
|
|
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.0;
|
|
32
|
-
return s * math.exp2(e) * (m * 1.1920928955078125e-7);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Decode RGBA vector to 32 bit float value.
|
|
37
|
-
* @function
|
|
38
|
-
* @param {Vec4} rgba - RGBA encoded 32 bit float value.
|
|
39
|
-
* @returns {number} - Float value.
|
|
40
|
-
*/
|
|
41
|
-
export function decodeFloatFromRGBAArr(arr, use32) {
|
|
42
|
-
var s = 1.0 - math.step(128.0, arr[0]) * 2.0;
|
|
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.0;
|
|
45
|
-
return s * math.exp2(e) * (m * 1.1920928955078125e-7);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Separate 64 bit value to two 32 bit float values.
|
|
50
|
-
* @function
|
|
51
|
-
* @param {number} value - Double type value.
|
|
52
|
-
* @returns {Array.<number>} Encoded array. (exactly 2 entries)
|
|
53
|
-
*/
|
|
54
|
-
export function doubleToTwoFloats(value) {
|
|
55
|
-
var high, low;
|
|
56
|
-
if (value >= 0.0) {
|
|
57
|
-
let doubleHigh = Math.floor(value / 65536.0) * 65536.0;
|
|
58
|
-
high = Math.fround(doubleHigh);
|
|
59
|
-
low = Math.fround(value - doubleHigh);
|
|
60
|
-
} else {
|
|
61
|
-
let doubleHigh = Math.floor(-value / 65536.0) * 65536.0;
|
|
62
|
-
high = Math.fround(-doubleHigh);
|
|
63
|
-
low = Math.fround(value + doubleHigh);
|
|
64
|
-
}
|
|
65
|
-
return new Float32Array([high, low]);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Separate 64 bit value to two 32 bit float values.
|
|
70
|
-
* @function
|
|
71
|
-
* @param {number} value - Double type value.
|
|
72
|
-
* @returns {Array.<number>} Encoded array. (exactly 2 entries)
|
|
73
|
-
*/
|
|
74
|
-
export function doubleToTwoFloats2(value, highLowArr) {
|
|
75
|
-
if (value >= 0.0) {
|
|
76
|
-
let doubleHigh = Math.floor(value / 65536.0) * 65536.0;
|
|
77
|
-
highLowArr[0] = Math.fround(doubleHigh);
|
|
78
|
-
highLowArr[1] = Math.fround(value - doubleHigh);
|
|
79
|
-
} else {
|
|
80
|
-
let doubleHigh = Math.floor(-value / 65536.0) * 65536.0;
|
|
81
|
-
highLowArr[0] = Math.fround(-doubleHigh);
|
|
82
|
-
highLowArr[1] = Math.fround(value + doubleHigh);
|
|
83
|
-
}
|
|
84
|
-
return highLowArr;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Separate 64 bit value to two 32 bit float values.
|
|
89
|
-
* @function
|
|
90
|
-
* @param {number} value - Double type value.
|
|
91
|
-
* @returns {Array.<number>} Encoded array. (exactly 2 entries)
|
|
92
|
-
*/
|
|
93
|
-
export function doubleToTwoFloatsV2(value, highLowVec) {
|
|
94
|
-
if (value >= 0.0) {
|
|
95
|
-
let doubleHigh = Math.floor(value / 65536.0) * 65536.0;
|
|
96
|
-
highLowVec.x = Math.fround(doubleHigh);
|
|
97
|
-
highLowVec.y = Math.fround(value - doubleHigh);
|
|
98
|
-
} else {
|
|
99
|
-
let doubleHigh = Math.floor(-value / 65536.0) * 65536.0;
|
|
100
|
-
highLowVec.x = Math.fround(-doubleHigh);
|
|
101
|
-
highLowVec.y = Math.fround(value + doubleHigh);
|
|
102
|
-
}
|
|
103
|
-
return highLowVec;
|
|
104
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @module og/math/coder
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
import * as math from "../math.js";
|
|
8
|
+
import { Vec4 } from "./Vec4.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Encode 32 bit float value to the RGBA vector.
|
|
12
|
+
* @function
|
|
13
|
+
* @param {number} v - 32 bit float value.
|
|
14
|
+
* @returns {math.Vec4} - RGBA vector value.
|
|
15
|
+
*/
|
|
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);
|
|
18
|
+
var yzww = new Vec4(enc.y / 255, enc.z / 255, enc.w / 255, 0);
|
|
19
|
+
return enc.subA(yzww);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Decode RGBA vector to 32 bit float value.
|
|
24
|
+
* @function
|
|
25
|
+
* @param {Vec4} rgba - RGBA encoded 32 bit float value.
|
|
26
|
+
* @returns {number} - Float value.
|
|
27
|
+
*/
|
|
28
|
+
export function decodeFloatFromRGBA(rgba) {
|
|
29
|
+
var s = 1.0 - math.step(128.0, rgba.x) * 2.0;
|
|
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.0;
|
|
32
|
+
return s * math.exp2(e) * (m * 1.1920928955078125e-7);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Decode RGBA vector to 32 bit float value.
|
|
37
|
+
* @function
|
|
38
|
+
* @param {Vec4} rgba - RGBA encoded 32 bit float value.
|
|
39
|
+
* @returns {number} - Float value.
|
|
40
|
+
*/
|
|
41
|
+
export function decodeFloatFromRGBAArr(arr, use32) {
|
|
42
|
+
var s = 1.0 - math.step(128.0, arr[0]) * 2.0;
|
|
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.0;
|
|
45
|
+
return s * math.exp2(e) * (m * 1.1920928955078125e-7);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Separate 64 bit value to two 32 bit float values.
|
|
50
|
+
* @function
|
|
51
|
+
* @param {number} value - Double type value.
|
|
52
|
+
* @returns {Array.<number>} Encoded array. (exactly 2 entries)
|
|
53
|
+
*/
|
|
54
|
+
export function doubleToTwoFloats(value) {
|
|
55
|
+
var high, low;
|
|
56
|
+
if (value >= 0.0) {
|
|
57
|
+
let doubleHigh = Math.floor(value / 65536.0) * 65536.0;
|
|
58
|
+
high = Math.fround(doubleHigh);
|
|
59
|
+
low = Math.fround(value - doubleHigh);
|
|
60
|
+
} else {
|
|
61
|
+
let doubleHigh = Math.floor(-value / 65536.0) * 65536.0;
|
|
62
|
+
high = Math.fround(-doubleHigh);
|
|
63
|
+
low = Math.fround(value + doubleHigh);
|
|
64
|
+
}
|
|
65
|
+
return new Float32Array([high, low]);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Separate 64 bit value to two 32 bit float values.
|
|
70
|
+
* @function
|
|
71
|
+
* @param {number} value - Double type value.
|
|
72
|
+
* @returns {Array.<number>} Encoded array. (exactly 2 entries)
|
|
73
|
+
*/
|
|
74
|
+
export function doubleToTwoFloats2(value, highLowArr) {
|
|
75
|
+
if (value >= 0.0) {
|
|
76
|
+
let doubleHigh = Math.floor(value / 65536.0) * 65536.0;
|
|
77
|
+
highLowArr[0] = Math.fround(doubleHigh);
|
|
78
|
+
highLowArr[1] = Math.fround(value - doubleHigh);
|
|
79
|
+
} else {
|
|
80
|
+
let doubleHigh = Math.floor(-value / 65536.0) * 65536.0;
|
|
81
|
+
highLowArr[0] = Math.fround(-doubleHigh);
|
|
82
|
+
highLowArr[1] = Math.fround(value + doubleHigh);
|
|
83
|
+
}
|
|
84
|
+
return highLowArr;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Separate 64 bit value to two 32 bit float values.
|
|
89
|
+
* @function
|
|
90
|
+
* @param {number} value - Double type value.
|
|
91
|
+
* @returns {Array.<number>} Encoded array. (exactly 2 entries)
|
|
92
|
+
*/
|
|
93
|
+
export function doubleToTwoFloatsV2(value, highLowVec) {
|
|
94
|
+
if (value >= 0.0) {
|
|
95
|
+
let doubleHigh = Math.floor(value / 65536.0) * 65536.0;
|
|
96
|
+
highLowVec.x = Math.fround(doubleHigh);
|
|
97
|
+
highLowVec.y = Math.fround(value - doubleHigh);
|
|
98
|
+
} else {
|
|
99
|
+
let doubleHigh = Math.floor(-value / 65536.0) * 65536.0;
|
|
100
|
+
highLowVec.x = Math.fround(-doubleHigh);
|
|
101
|
+
highLowVec.y = Math.fround(value + doubleHigh);
|
|
102
|
+
}
|
|
103
|
+
return highLowVec;
|
|
104
|
+
}
|
package/src/og/math.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module og/math
|
|
3
3
|
*/
|
|
4
|
+
|
|
4
5
|
"use strict";
|
|
5
6
|
|
|
6
7
|
/** @const */
|
|
@@ -49,12 +50,12 @@ export const DEGREES_TO_HOURS = 1.0 / 15.0;
|
|
|
49
50
|
/** @const */
|
|
50
51
|
export const SQRT_HALF = Math.sqrt(0.5);
|
|
51
52
|
|
|
52
|
-
export const EPS1 =
|
|
53
|
-
export const EPS2 =
|
|
54
|
-
export const EPS3 =
|
|
55
|
-
export const EPS4 =
|
|
56
|
-
export const EPS5 =
|
|
57
|
-
export const EPS6 =
|
|
53
|
+
export const EPS1 = 1e-1;
|
|
54
|
+
export const EPS2 = 1e-2;
|
|
55
|
+
export const EPS3 = 1e-3;
|
|
56
|
+
export const EPS4 = 1e-4;
|
|
57
|
+
export const EPS5 = 1e-5;
|
|
58
|
+
export const EPS6 = 1e-6;
|
|
58
59
|
export const EPS7 = 1e-7;
|
|
59
60
|
export const EPS8 = 1e-8;
|
|
60
61
|
export const EPS9 = 1e-9;
|
|
@@ -226,7 +227,7 @@ export function step(edge, x) {
|
|
|
226
227
|
*/
|
|
227
228
|
export function frac(x) {
|
|
228
229
|
const mx = Math.abs(x)
|
|
229
|
-
return
|
|
230
|
+
return mx - Math.floor(mx);
|
|
230
231
|
}
|
|
231
232
|
|
|
232
233
|
/**
|
|
@@ -396,3 +397,34 @@ export function solve_iteration(f, x0, err, maxIter = 50) {
|
|
|
396
397
|
* @callback equationCallback
|
|
397
398
|
* @param {number} x - Equation variable.
|
|
398
399
|
*/
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
*
|
|
403
|
+
* @param a - First bearing angle
|
|
404
|
+
* @param b - Second bearing angle
|
|
405
|
+
* @returns {number}
|
|
406
|
+
*/
|
|
407
|
+
function getAngleDirection(a, b) {
|
|
408
|
+
let a_y = Math.cos(a),
|
|
409
|
+
a_x = Math.sin(a),
|
|
410
|
+
b_y = Math.cos(b),
|
|
411
|
+
b_x = Math.sin(b);
|
|
412
|
+
let c = a_y * b_x - b_y * a_x,
|
|
413
|
+
d = a_x * b_x + a_y * b_y;
|
|
414
|
+
if (c > 0.0) {
|
|
415
|
+
return Math.acos(d);
|
|
416
|
+
}
|
|
417
|
+
return -Math.acos(d);
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Returns angle between two azimuths
|
|
422
|
+
* @param {number} a - First azimuth angle
|
|
423
|
+
* @param {number} b - Second azimuth angle
|
|
424
|
+
* @returns {number}
|
|
425
|
+
*/
|
|
426
|
+
export function getAngleBetweenAzimuths(a, b) {
|
|
427
|
+
a = zeroTwoPI(a);
|
|
428
|
+
b = zeroTwoPI(b);
|
|
429
|
+
return ((((a - b) % 360) + 360 + 180) % 360) - 180;
|
|
430
|
+
}
|
package/src/og/proj/EPSG3857.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module og/proj/EPSG3857
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
"use strict";
|
|
6
|
-
|
|
7
|
-
import { Proj, Units } from "./Proj.js";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* EPSG:3857 projection object.
|
|
11
|
-
* @type {Proj}
|
|
12
|
-
*/
|
|
13
|
-
export const EPSG3857 = new Proj({ code: "epsg:3857", units: Units.METERS });
|
|
1
|
+
/**
|
|
2
|
+
* @module og/proj/EPSG3857
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
import { Proj, Units } from "./Proj.js";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* EPSG:3857 projection object.
|
|
11
|
+
* @type {Proj}
|
|
12
|
+
*/
|
|
13
|
+
export const EPSG3857 = new Proj({ code: "epsg:3857", units: Units.METERS });
|