@openglobus/og 0.11.5 → 0.12.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/css/og.css +5 -2
- package/package.json +12 -14
- package/src/og/Clock.js +6 -10
- package/src/og/Events.js +5 -7
- package/src/og/Extent.js +73 -32
- package/src/og/Globe.js +25 -10
- package/src/og/ImageCanvas.js +18 -15
- package/src/og/LonLat.js +13 -10
- package/src/og/Popup.js +19 -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/Camera.js +70 -79
- package/src/og/camera/Frustum.js +19 -12
- package/src/og/camera/PlanetCamera.js +33 -34
- package/src/og/control/CompassButton.js +1 -2
- package/src/og/control/Control.js +7 -9
- package/src/og/control/DebugInfo.js +2 -3
- package/src/og/control/EarthNavigation.js +26 -17
- package/src/og/control/KeyboardNavigation.js +9 -9
- package/src/og/control/LayerSwitcher.js +21 -20
- package/src/og/control/Lighting.js +74 -64
- package/src/og/control/MouseNavigation.js +30 -29
- package/src/og/control/MouseWheelZoomControl.js +257 -0
- 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 +24 -14
- 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/control/index.js +2 -0
- package/src/og/control/visibleExtent/Segment.js +1862 -0
- package/src/og/control/visibleExtent/VisibleExtent.js +80 -0
- package/src/og/control/visibleExtent/drawnode.js +751 -0
- package/src/og/ellipsoid/Ellipsoid.js +149 -57
- package/src/og/ellipsoid/wgs84.js +3 -3
- package/src/og/entity/BaseBillboard.js +72 -30
- package/src/og/entity/Billboard.js +9 -5
- package/src/og/entity/BillboardHandler.js +315 -62
- package/src/og/entity/Entity.js +742 -704
- package/src/og/entity/EntityCollection.js +47 -24
- package/src/og/entity/GeoObject.js +228 -0
- package/src/og/entity/GeoObjectHandler.js +895 -0
- package/src/og/entity/GeometryHandler.js +595 -123
- package/src/og/entity/Label.js +62 -30
- package/src/og/entity/LabelHandler.js +42 -243
- package/src/og/entity/LabelWorker.js +218 -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 -17
- package/src/og/layer/GeoImage.js +8 -16
- package/src/og/layer/GeoTexture2d.js +2 -10
- package/src/og/layer/GeoVideo.js +2 -10
- package/src/og/layer/KML.js +55 -33
- package/src/og/layer/Layer.js +24 -33
- package/src/og/layer/Material.js +1 -1
- package/src/og/layer/Vector.js +94 -48
- package/src/og/layer/WMS.js +33 -18
- package/src/og/layer/XYZ.js +24 -26
- 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 +78 -32
- 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 +50 -95
- package/src/og/quadTree/quadTree.js +1 -1
- package/src/og/renderer/Renderer.js +106 -126
- package/src/og/renderer/RendererEvents.js +45 -23
- package/src/og/scene/BaseNode.js +2 -3
- package/src/og/scene/Planet.js +139 -191
- package/src/og/scene/RenderNode.js +15 -8
- package/src/og/segment/Segment.js +93 -268
- package/src/og/segment/Slice.js +45 -0
- package/src/og/shaders/drawnode.js +174 -360
- 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/shaders/toneMapping.js +1 -0
- package/src/og/shapes/BaseShape.js +108 -36
- package/src/og/shapes/Icosphere.js +25 -10
- package/src/og/shapes/Sphere.js +8 -11
- package/src/og/terrain/EmptyTerrain.js +3 -2
- package/src/og/terrain/GlobusTerrain.js +2 -0
- package/src/og/utils/FontAtlas.js +6 -2
- package/src/og/utils/GeoImageCreator.js +5 -1
- package/src/og/utils/Loader.js +1 -1
- package/src/og/utils/PlainSegmentWorker.js +0 -13
- package/src/og/utils/TextureAtlas.js +18 -20
- package/src/og/utils/VectorTileCreator.js +1 -3
- package/src/og/utils/shared.js +2 -2
- package/src/og/webgl/Handler.js +219 -162
- 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/Clock.d.ts +0 -94
- package/types/Deferred.d.ts +0 -6
- package/types/Events.d.ts +0 -77
- package/types/Extent.d.ts +0 -166
- package/types/Globe.d.ts +0 -82
- package/types/ImageCanvas.d.ts +0 -123
- package/types/Lock.d.ts +0 -12
- package/types/LonLat.d.ts +0 -108
- package/types/Popup.d.ts +0 -42
- package/types/QueueArray.d.ts +0 -19
- package/types/Rectangle.d.ts +0 -80
- package/types/Stack.d.ts +0 -19
- package/types/ajax.d.ts +0 -24
- package/types/arial.d.ts +0 -48
- package/types/astro/astro.d.ts +0 -38
- package/types/astro/earth.d.ts +0 -7
- package/types/astro/jd.d.ts +0 -254
- package/types/bv/Box.d.ts +0 -30
- package/types/bv/Sphere.d.ts +0 -38
- package/types/bv/index.d.ts +0 -3
- package/types/camera/Camera.d.ts +0 -312
- package/types/camera/Frustum.d.ts +0 -133
- package/types/camera/PlanetCamera.d.ts +0 -218
- package/types/camera/index.d.ts +0 -3
- package/types/cons.d.ts +0 -40
- package/types/control/CompassButton.d.ts +0 -17
- package/types/control/Control.d.ts +0 -104
- package/types/control/DebugInfo.d.ts +0 -15
- package/types/control/EarthCoordinates.d.ts +0 -47
- package/types/control/EarthNavigation.d.ts +0 -42
- package/types/control/GeoImageDragControl.d.ts +0 -6
- package/types/control/KeyboardNavigation.d.ts +0 -21
- package/types/control/LayerSwitcher.d.ts +0 -21
- package/types/control/Lighting.d.ts +0 -16
- package/types/control/MouseNavigation.d.ts +0 -47
- package/types/control/ScaleControl.d.ts +0 -22
- package/types/control/ShowFps.d.ts +0 -11
- package/types/control/SimpleNavigation.d.ts +0 -25
- package/types/control/Sun.d.ts +0 -50
- package/types/control/ToggleWireframe.d.ts +0 -12
- package/types/control/TouchNavigation.d.ts +0 -48
- package/types/control/ZoomControl.d.ts +0 -27
- package/types/control/index.d.ts +0 -17
- package/types/ellipsoid/Ellipsoid.d.ts +0 -146
- package/types/ellipsoid/index.d.ts +0 -3
- package/types/ellipsoid/wgs84.d.ts +0 -6
- package/types/entity/BaseBillboard.d.ts +0 -208
- package/types/entity/Billboard.d.ts +0 -94
- package/types/entity/BillboardHandler.d.ts +0 -78
- package/types/entity/Entity.d.ts +0 -333
- package/types/entity/EntityCollection.d.ts +0 -311
- package/types/entity/Geometry.d.ts +0 -74
- package/types/entity/GeometryHandler.d.ts +0 -76
- package/types/entity/Label.d.ts +0 -189
- package/types/entity/LabelHandler.d.ts +0 -29
- package/types/entity/PointCloud.d.ts +0 -174
- package/types/entity/PointCloudHandler.d.ts +0 -38
- package/types/entity/Polyline.d.ts +0 -306
- package/types/entity/PolylineHandler.d.ts +0 -18
- package/types/entity/Ray.d.ts +0 -124
- package/types/entity/RayHandler.d.ts +0 -67
- package/types/entity/ShapeHandler.d.ts +0 -22
- package/types/entity/Strip.d.ts +0 -119
- package/types/entity/StripHandler.d.ts +0 -38
- package/types/entity/index.d.ts +0 -8
- package/types/index.core.d.ts +0 -65
- package/types/index.d.ts +0 -45
- package/types/index.webgl.d.ts +0 -7
- package/types/input/KeyboardHandler.d.ts +0 -10
- package/types/input/MouseHandler.d.ts +0 -5
- package/types/input/TouchHandler.d.ts +0 -5
- package/types/input/input.d.ts +0 -34
- package/types/layer/BaseGeoImage.d.ts +0 -94
- package/types/layer/CanvasTiles.d.ts +0 -68
- package/types/layer/GeoImage.d.ts +0 -52
- package/types/layer/GeoTexture2d.d.ts +0 -8
- package/types/layer/GeoVideo.d.ts +0 -55
- package/types/layer/KML.d.ts +0 -63
- package/types/layer/Layer.d.ts +0 -326
- package/types/layer/Material.d.ts +0 -45
- package/types/layer/Vector.d.ts +0 -208
- package/types/layer/WMS.d.ts +0 -63
- package/types/layer/XYZ.d.ts +0 -120
- package/types/layer/index.d.ts +0 -10
- package/types/light/LightSource.d.ts +0 -178
- package/types/math/Line2.d.ts +0 -11
- package/types/math/Line3.d.ts +0 -10
- package/types/math/Mat3.d.ts +0 -65
- package/types/math/Mat4.d.ts +0 -176
- package/types/math/Plane.d.ts +0 -18
- package/types/math/Quat.d.ts +0 -379
- package/types/math/Ray.d.ts +0 -82
- package/types/math/Vec2.d.ts +0 -309
- package/types/math/Vec3.d.ts +0 -460
- package/types/math/Vec4.d.ts +0 -162
- package/types/math/coder.d.ts +0 -43
- package/types/math/index.d.ts +0 -11
- package/types/math.d.ts +0 -261
- package/types/mercator.d.ts +0 -92
- package/types/proj/EPSG3857.d.ts +0 -6
- package/types/proj/EPSG4326.d.ts +0 -6
- package/types/proj/Proj.d.ts +0 -42
- package/types/quadTree/EntityCollectionNode.d.ts +0 -34
- package/types/quadTree/Node.d.ts +0 -61
- package/types/quadTree/quadTree.d.ts +0 -40
- package/types/renderer/Renderer.d.ts +0 -298
- package/types/renderer/RendererEvents.d.ts +0 -233
- package/types/res/images.d.ts +0 -3
- package/types/scene/Axes.d.ts +0 -11
- package/types/scene/BaseNode.d.ts +0 -60
- package/types/scene/Planet.d.ts +0 -577
- package/types/scene/RenderNode.d.ts +0 -142
- package/types/scene/SkyBox.d.ts +0 -10
- package/types/scene/index.d.ts +0 -4
- package/types/segment/Segment.d.ts +0 -279
- package/types/segment/SegmentLonLat.d.ts +0 -16
- package/types/segment/segmentHelper.d.ts +0 -13
- package/types/shaders/billboard.d.ts +0 -3
- package/types/shaders/depth.d.ts +0 -2
- package/types/shaders/drawnode.d.ts +0 -7
- package/types/shaders/label.d.ts +0 -4
- package/types/shaders/pointCloud.d.ts +0 -2
- package/types/shaders/polyline.d.ts +0 -3
- package/types/shaders/ray.d.ts +0 -2
- package/types/shaders/screenFrame.d.ts +0 -2
- package/types/shaders/shape.d.ts +0 -4
- package/types/shaders/skybox.d.ts +0 -2
- package/types/shaders/toneMapping.d.ts +0 -2
- package/types/shapes/BaseShape.d.ts +0 -250
- package/types/shapes/Sphere.d.ts +0 -41
- package/types/terrain/BilTerrain.d.ts +0 -7
- package/types/terrain/EmptyTerrain.d.ts +0 -72
- package/types/terrain/Geoid.d.ts +0 -26
- package/types/terrain/GlobusTerrain.d.ts +0 -116
- package/types/terrain/MapboxTerrain.d.ts +0 -7
- package/types/terrain/index.d.ts +0 -5
- package/types/utils/FontAtlas.d.ts +0 -14
- package/types/utils/GeoImageCreator.d.ts +0 -30
- package/types/utils/ImagesCacheManager.d.ts +0 -10
- package/types/utils/Loader.d.ts +0 -25
- package/types/utils/NormalMapCreator.d.ts +0 -39
- package/types/utils/PlainSegmentWorker.d.ts +0 -10
- package/types/utils/TerrainWorker.d.ts +0 -9
- package/types/utils/TextureAtlas.d.ts +0 -111
- package/types/utils/VectorTileCreator.d.ts +0 -16
- package/types/utils/colorTable.d.ts +0 -143
- package/types/utils/earcut.d.ts +0 -6
- package/types/utils/shared.d.ts +0 -231
- package/types/webgl/Framebuffer.d.ts +0 -135
- package/types/webgl/Handler.d.ts +0 -388
- package/types/webgl/Multisample.d.ts +0 -89
- package/types/webgl/Program.d.ts +0 -155
- package/types/webgl/ProgramController.d.ts +0 -89
- package/types/webgl/callbacks.d.ts +0 -1
- package/types/webgl/index.d.ts +0 -6
- package/types/webgl/types.d.ts +0 -2
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) {
|
|
@@ -679,8 +699,24 @@ export class Vec3 {
|
|
|
679
699
|
* @param {Vec3} point3 - Distant point.
|
|
680
700
|
* @returns {number} -
|
|
681
701
|
*/
|
|
682
|
-
distance(point3) {
|
|
683
|
-
|
|
702
|
+
distance(point3) {
|
|
703
|
+
let dx = this.x - point3.x,
|
|
704
|
+
dy = this.y - point3.y,
|
|
705
|
+
dz = this.z - point3.z;
|
|
706
|
+
return Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
/**
|
|
710
|
+
* Gets square distance to point.
|
|
711
|
+
* @public
|
|
712
|
+
* @param {Vec3} point3 - Distant point.
|
|
713
|
+
* @returns {number} -
|
|
714
|
+
*/
|
|
715
|
+
distance2(point3) {
|
|
716
|
+
let dx = this.x - point3.x,
|
|
717
|
+
dy = this.y - point3.y,
|
|
718
|
+
dz = this.z - point3.z;
|
|
719
|
+
return dx * dx + dy * dy + dz * dz;
|
|
684
720
|
}
|
|
685
721
|
|
|
686
722
|
/**
|
|
@@ -750,7 +786,11 @@ export class Vec3 {
|
|
|
750
786
|
* @returns {Vec3} -
|
|
751
787
|
*/
|
|
752
788
|
lerp(v2, l) {
|
|
753
|
-
return new Vec3(
|
|
789
|
+
return new Vec3(
|
|
790
|
+
this.x + (v2.x - this.x) * l,
|
|
791
|
+
this.y + (v2.y - this.y) * l,
|
|
792
|
+
this.z + (v2.z - this.z) * l
|
|
793
|
+
);
|
|
754
794
|
}
|
|
755
795
|
|
|
756
796
|
/**
|
|
@@ -762,18 +802,24 @@ export class Vec3 {
|
|
|
762
802
|
*/
|
|
763
803
|
smerp(v2, t) {
|
|
764
804
|
var one_d = 1 - t;
|
|
765
|
-
return new Vec3(
|
|
805
|
+
return new Vec3(
|
|
806
|
+
this.x * t + v2.x * one_d,
|
|
807
|
+
this.y * t + v2.y * one_d,
|
|
808
|
+
this.z * t + v2.z * one_d
|
|
809
|
+
);
|
|
766
810
|
}
|
|
767
811
|
|
|
768
|
-
static get LERP_DELTA() {
|
|
812
|
+
static get LERP_DELTA() {
|
|
813
|
+
return 1e-6;
|
|
814
|
+
}
|
|
769
815
|
|
|
770
816
|
/**
|
|
771
817
|
* 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
|
|
818
|
+
* Interpolates between current and v2 vector by amount t. The difference between this and linear interpolation (aka, "lerp") is that
|
|
819
|
+
* the vectors are treated as directions rather than points in space. The direction of the returned vector is interpolated
|
|
774
820
|
* by the angle and its magnitude is interpolated between the magnitudes of from and to.
|
|
775
821
|
* @public
|
|
776
|
-
* @param {Vec3} v2 -
|
|
822
|
+
* @param {Vec3} v2 -
|
|
777
823
|
* @param {number} t - The parameter t is clamped to the range [0, 1].
|
|
778
824
|
* @returns {Vec3} -
|
|
779
825
|
*/
|
|
@@ -791,7 +837,7 @@ export class Vec3 {
|
|
|
791
837
|
var omega, sinom, scale0, scale1;
|
|
792
838
|
var cosom = this.dot(v2);
|
|
793
839
|
|
|
794
|
-
if (
|
|
840
|
+
if (1.0 - cosom > Vec3.LERP_DELTA) {
|
|
795
841
|
omega = Math.acos(cosom);
|
|
796
842
|
sinom = Math.sin(omega);
|
|
797
843
|
scale0 = Math.sin((1.0 - t) * omega) / sinom;
|
|
@@ -825,14 +871,15 @@ export class Vec3 {
|
|
|
825
871
|
return Quat.IDENTITY.clone();
|
|
826
872
|
}
|
|
827
873
|
|
|
828
|
-
if (d <
|
|
874
|
+
if (d < 1e-6 - 1.0) {
|
|
829
875
|
if (!fallbackAxis.isEqual(Vec3.ZERO)) {
|
|
830
876
|
// rotate 180 degrees about the fallback axis
|
|
831
877
|
return Quat.axisAngleToQuat(Math.PI, fallbackAxis);
|
|
832
878
|
} else {
|
|
833
879
|
// Generate an axis
|
|
834
880
|
let axis = Vec3.UNIT_X.cross(v0);
|
|
835
|
-
if (axis.isZero()) {
|
|
881
|
+
if (axis.isZero()) {
|
|
882
|
+
// pick another if colinear
|
|
836
883
|
axis = Vec3.UNIT_Y.cross(v0);
|
|
837
884
|
}
|
|
838
885
|
axis.normalize();
|
|
@@ -862,4 +909,3 @@ export class Vec3 {
|
|
|
862
909
|
export function vec3(x, y, z) {
|
|
863
910
|
return new Vec3(x, y, z);
|
|
864
911
|
}
|
|
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 };
|