@openglobus/og 0.15.5 → 0.16.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 -1
- 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 +13 -15
- package/src/og/Globe.js +5 -2
- package/src/og/LonLat.js +18 -1
- package/src/og/Object3d.js +21 -2
- package/src/og/bv/index.js +2 -2
- package/src/og/camera/PlanetCamera.js +4 -10
- package/src/og/control/LayerSwitcher.js +4 -3
- package/src/og/control/RulerSwitcher.js +2 -2
- package/src/og/control/ZoomControl.js +2 -2
- package/src/og/control/heightRuler/HeightRulerScene.js +6 -2
- package/src/og/control/index.js +5 -2
- package/src/og/control/ruler/RulerScene.js +11 -8
- package/src/og/control/timeline/TimelineControl.js +5 -3
- package/src/og/control/timeline/TimelineModel.js +4 -0
- package/src/og/control/timeline/TimelineView.js +10 -3
- package/src/og/control/visibleExtent/Segment.js +36 -42
- package/src/og/ellipsoid/Ellipsoid.js +23 -10
- package/src/og/entity/Entity.js +3 -3
- package/src/og/entity/EntityCollection.js +2 -2
- package/src/og/entity/Label.js +1 -1
- package/src/og/entity/Polyline.js +4 -2
- package/src/og/index.js +4 -7
- package/src/og/layer/CanvasTiles.js +70 -23
- package/src/og/layer/GeoImage.js +40 -18
- package/src/og/layer/Vector.js +14 -11
- package/src/og/layer/WMS.js +2 -2
- package/src/og/math.js +2 -1
- package/src/og/quadTree/EPSG4326QuadTreeStrategy.js +26 -0
- package/src/og/quadTree/Node.js +44 -50
- package/src/og/quadTree/index.js +2 -0
- package/src/og/renderer/Renderer.js +13 -1
- package/src/og/scene/Planet.js +4 -4
- package/src/og/scene/index.js +3 -3
- package/src/og/segment/Segment.js +88 -76
- package/src/og/shaders/drawnode.js +138 -89
- package/src/og/shaders/geoObject.js +57 -46
- package/src/og/shaders/ray.js +15 -21
- package/src/og/terrain/EmptyTerrain.js +19 -7
- package/src/og/terrain/GlobusTerrain.js +23 -18
- package/src/og/terrain/MapboxTerrain.js +7 -8
- package/src/og/terrain/index.js +4 -4
- package/src/og/utils/objParser.js +227 -0
- package/src/og/utils/shared.js +9 -0
- package/src/og/webgl/Handler.js +1 -3
- package/types/Globe.d.ts +2 -0
- package/types/LonLat.d.ts +12 -1
- package/types/Object3d.d.ts +2 -0
- package/types/Popup.d.ts +1 -1
- package/types/bv/index.d.ts +2 -2
- package/types/camera/PlanetCamera.d.ts +0 -7
- package/types/camera/index.d.ts +2 -2
- package/types/control/GeoImageDragControl.d.ts +1 -1
- package/types/control/LayerAnimation.d.ts +1 -1
- package/types/control/Lighting.d.ts +2 -2
- package/types/control/heightRuler/HeightRulerScene.d.ts +1 -1
- package/types/control/index.d.ts +3 -2
- package/types/control/ruler/RulerScene.d.ts +5 -4
- package/types/control/selection/SelectionScene.d.ts +3 -3
- package/types/control/timeline/TimelineControl.d.ts +10 -0
- package/types/control/timeline/TimelineModel.d.ts +33 -0
- package/types/control/timeline/TimelineView.d.ts +57 -0
- package/types/control/timeline/timelineUtils.d.ts +9 -0
- package/types/ellipsoid/Ellipsoid.d.ts +16 -9
- package/types/ellipsoid/index.d.ts +2 -2
- package/types/entity/Entity.d.ts +3 -3
- package/types/entity/EntityCollection.d.ts +2 -2
- package/types/entity/Label.d.ts +1 -1
- package/types/entity/Polyline.d.ts +1 -0
- package/types/index.d.ts +45 -46
- package/types/layer/CanvasTiles.d.ts +2 -1
- package/types/layer/GeoImage.d.ts +7 -1
- package/types/layer/GeoTexture2d.d.ts +1 -1
- package/types/layer/Vector.d.ts +3 -3
- package/types/layer/index.d.ts +9 -9
- package/types/math/Line2.d.ts +1 -1
- package/types/math/Line3.d.ts +1 -1
- package/types/math/index.d.ts +10 -10
- package/types/mercator.d.ts +1 -1
- package/types/quadTree/EPSG4326QuadTreeStrategy.d.ts +3 -0
- package/types/quadTree/EntityCollectionNode.d.ts +1 -1
- package/types/quadTree/index.d.ts +2 -0
- package/types/renderer/Renderer.d.ts +2 -2
- package/types/scene/Axes.d.ts +1 -1
- package/types/scene/SkyBox.d.ts +1 -1
- package/types/scene/index.d.ts +3 -3
- package/types/segment/Segment.d.ts +9 -11
- package/types/shaders/atmos.d.ts +1 -1
- package/types/shaders/billboard.d.ts +1 -1
- package/types/shaders/depth.d.ts +1 -1
- package/types/shaders/label.d.ts +1 -1
- package/types/shaders/pickingMask.d.ts +1 -1
- package/types/shaders/pointCloud.d.ts +1 -1
- package/types/shaders/polyline.d.ts +1 -1
- package/types/shaders/ray.d.ts +1 -1
- package/types/shaders/screenFrame.d.ts +1 -1
- package/types/shaders/skybox.d.ts +1 -1
- package/types/shaders/toneMapping.d.ts +1 -1
- package/types/terrain/BilTerrain.d.ts +1 -0
- package/types/terrain/EmptyTerrain.d.ts +13 -2
- package/types/terrain/GlobusTerrain.d.ts +2 -1
- package/types/terrain/MapboxTerrain.d.ts +1 -3
- package/types/terrain/index.d.ts +4 -4
- package/types/ui/Button.d.ts +1 -1
- package/types/ui/ButtonGroup.d.ts +12 -0
- package/types/ui/Dialog.d.ts +2 -2
- package/types/ui/Slider.d.ts +1 -1
- package/types/ui/ToggleButton.d.ts +1 -1
- package/types/ui/View.d.ts +1 -1
- package/types/utils/GeoImageCreator.d.ts +2 -2
- package/types/utils/ImagesCacheManager.d.ts +1 -1
- package/types/utils/Loader.d.ts +1 -1
- package/types/utils/VectorTileCreator.d.ts +1 -1
- package/types/utils/objParser.d.ts +8 -0
- package/types/utils/shared.d.ts +6 -0
- package/types/webgl/Handler.d.ts +2 -2
- package/src/og/index.core.js +0 -116
- package/src/og/index.webgl.js +0 -17
- package/types/index.core.d.ts +0 -65
- package/types/index.webgl.d.ts +0 -7
|
@@ -9,11 +9,18 @@ import { Geoid } from "./Geoid.js";
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Class represents terrain provider without elevation data.
|
|
12
|
-
* @
|
|
12
|
+
* @param {Object} [options] - Provider options:
|
|
13
|
+
* @param {string} [options.name="empty"] - Provider name.
|
|
14
|
+
* @param {number} [options.minZoom=2] - Minimal visible zoom index when terrain handler works.
|
|
15
|
+
* @param {number} [options.minZoom=50] - Maximal visible zoom index when terrain handler works.
|
|
16
|
+
* @param {number} [options.minNativeZoom=50] - Maximal available terrain zoom level.
|
|
17
|
+
* @param {Array.<number>} [options.gridSizeByZoom] - Array of segment triangulation grid sizes where array index agreed to the segment zoom index.
|
|
18
|
+
* @param {Array.<number>} [gridSizeByZoom] - Array of values, where each value corresponds to the size of a tile(or segment) on the globe. Each value must be power of two.
|
|
13
19
|
*/
|
|
14
20
|
class EmptyTerrain {
|
|
15
21
|
constructor(options = {}) {
|
|
16
|
-
|
|
22
|
+
|
|
23
|
+
this.equalizeVertices = options.equalizeVertices || false;
|
|
17
24
|
|
|
18
25
|
this.equalizeNormals = false;
|
|
19
26
|
|
|
@@ -24,30 +31,35 @@ class EmptyTerrain {
|
|
|
24
31
|
* @public
|
|
25
32
|
* @type {string}
|
|
26
33
|
*/
|
|
27
|
-
this.name = "empty";
|
|
34
|
+
this.name = options.name || "empty";
|
|
28
35
|
|
|
29
36
|
/**
|
|
30
37
|
* Minimal z-index value for segment elevation data handling.
|
|
31
38
|
* @public
|
|
32
39
|
* @type {number}
|
|
33
40
|
*/
|
|
34
|
-
this.minZoom =
|
|
41
|
+
this.minZoom = options.minZoom || 2;
|
|
35
42
|
|
|
36
43
|
/**
|
|
37
44
|
* Maximal z-index value for segment elevation data handling.
|
|
38
45
|
* @public
|
|
39
46
|
* @type {number}
|
|
40
47
|
*/
|
|
41
|
-
this.maxZoom =
|
|
48
|
+
this.maxZoom = options.maxZoom || 50;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Maximal existent available zoom
|
|
52
|
+
* @type {number}
|
|
53
|
+
*/
|
|
54
|
+
this.maxNativeZoom = options.maxNativeZoom || this.maxZoom;
|
|
42
55
|
|
|
43
56
|
/**
|
|
44
57
|
* @public
|
|
45
58
|
* @type {Array.<number>}
|
|
46
59
|
*/
|
|
47
60
|
this.gridSizeByZoom = options.gridSizeByZoom || [
|
|
48
|
-
|
|
61
|
+
64, 32, 16, 8, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
|
|
49
62
|
];
|
|
50
|
-
//this.gridSizeByZoom = options.gridSizeByZoom || [32, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2];
|
|
51
63
|
|
|
52
64
|
this._maxNodeZoom = this.gridSizeByZoom.length - 1;
|
|
53
65
|
|
|
@@ -39,6 +39,7 @@ const EVENT_NAMES = [
|
|
|
39
39
|
* @param {Object} [options] - Provider options:
|
|
40
40
|
* @param {number} [options.minZoom=3] - Minimal visible zoom index when terrain handler works.
|
|
41
41
|
* @param {number} [options.minZoom=14] - Maximal visible zoom index when terrain handler works.
|
|
42
|
+
* @param {number} [options.minNativeZoom=14] - Maximal available terrain zoom level.
|
|
42
43
|
* @param {string} [options.url="//openglobus.org/heights/srtm3/{z}/{y}/{x}.ddm"] - Terrain source path url template. Default is openglobus ddm elevation file.
|
|
43
44
|
* @param {Array.<number>} [options.gridSizeByZoom] - Array of segment triangulation grid sizes where array index agreed to the segment zoom index.
|
|
44
45
|
* @param {number} [options.plainGridSize=32] - Elevation grid size. Default is 32x32. Must be power of two.
|
|
@@ -54,8 +55,14 @@ class GlobusTerrain extends EmptyTerrain {
|
|
|
54
55
|
* @param {*} [options]
|
|
55
56
|
*/
|
|
56
57
|
constructor(name, options = {}) {
|
|
57
|
-
super({
|
|
58
|
+
super({
|
|
59
|
+
geoidSrc: "//openglobus.org/geoid/egm84-30.pgm",
|
|
60
|
+
maxNativeZoom: options.maxNativeZoom || 14,
|
|
61
|
+
...options
|
|
62
|
+
});
|
|
63
|
+
|
|
58
64
|
this._s = options.subdomains || ["a", "b", "c"];
|
|
65
|
+
|
|
59
66
|
/**
|
|
60
67
|
* Events handler.
|
|
61
68
|
* @public
|
|
@@ -78,20 +85,6 @@ class GlobusTerrain extends EmptyTerrain {
|
|
|
78
85
|
*/
|
|
79
86
|
this.name = name || "openglobus";
|
|
80
87
|
|
|
81
|
-
/**
|
|
82
|
-
* Minimal visible zoom index when terrain handler works.
|
|
83
|
-
* @public
|
|
84
|
-
* @type {number}
|
|
85
|
-
*/
|
|
86
|
-
this.minZoom = options.minZoom || 2;
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Maximal visible zoom index when terrain handler works.
|
|
90
|
-
* @public
|
|
91
|
-
* @type {number}
|
|
92
|
-
*/
|
|
93
|
-
this.maxZoom = options.maxZoom || 14;
|
|
94
|
-
|
|
95
88
|
/**
|
|
96
89
|
* Terrain source path url template.
|
|
97
90
|
* @public
|
|
@@ -169,13 +162,15 @@ class GlobusTerrain extends EmptyTerrain {
|
|
|
169
162
|
return false;
|
|
170
163
|
}
|
|
171
164
|
|
|
172
|
-
getHeightAsync(lonLat, callback, zoom) {
|
|
165
|
+
getHeightAsync(lonLat, callback, zoom, firstAttempt) {
|
|
173
166
|
if (!lonLat || lonLat.lat > mercator.MAX_LAT || lonLat.lat < mercator.MIN_LAT) {
|
|
174
167
|
callback(0);
|
|
175
168
|
return true;
|
|
176
169
|
}
|
|
177
170
|
|
|
178
|
-
|
|
171
|
+
firstAttempt = firstAttempt != undefined ? firstAttempt : true;
|
|
172
|
+
|
|
173
|
+
let z = zoom || this.maxNativeZoom,
|
|
179
174
|
z2 = Math.pow(2, z),
|
|
180
175
|
size = mercator.POLE2 / z2,
|
|
181
176
|
merc = mercator.forward(lonLat),
|
|
@@ -214,12 +209,22 @@ class GlobusTerrain extends EmptyTerrain {
|
|
|
214
209
|
this._elevationCache[tileIndex] = cache;
|
|
215
210
|
callback(this._getGroundHeightMerc(merc, cache));
|
|
216
211
|
} else if (response.status === "error") {
|
|
212
|
+
|
|
213
|
+
if (firstAttempt && z > this.maxZoom) {
|
|
214
|
+
firstAttempt = false;
|
|
215
|
+
this.getHeightAsync(lonLat, callback, this.maxZoom, false);
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
|
|
217
219
|
let cache = {
|
|
218
220
|
heights: null,
|
|
219
221
|
extent: extent
|
|
220
222
|
};
|
|
223
|
+
|
|
221
224
|
this._elevationCache[tileIndex] = cache;
|
|
225
|
+
|
|
222
226
|
callback(0);
|
|
227
|
+
|
|
223
228
|
} else {
|
|
224
229
|
this._fetchCache[tileIndex] = null;
|
|
225
230
|
delete this._fetchCache[tileIndex];
|
|
@@ -475,4 +480,4 @@ class GlobusTerrain extends EmptyTerrain {
|
|
|
475
480
|
}
|
|
476
481
|
}
|
|
477
482
|
|
|
478
|
-
export { GlobusTerrain };
|
|
483
|
+
export { GlobusTerrain };
|
|
@@ -13,21 +13,20 @@ const rgb2Height = (r, g, b) => {
|
|
|
13
13
|
|
|
14
14
|
class MapboxTerrain extends GlobusTerrain {
|
|
15
15
|
constructor(name, options = {}) {
|
|
16
|
-
super(name || "mapbox",
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
options
|
|
16
|
+
super(name || "mapbox", {
|
|
17
|
+
equalizeVertices: options.equalizeVertices != undefined ? options.equalizeVertices : true,
|
|
18
|
+
maxZoom: options.maxZoom || 17,
|
|
19
|
+
...options
|
|
20
|
+
});
|
|
20
21
|
|
|
21
22
|
this.equalizeNormals = options.equalizeNormals || false;
|
|
22
23
|
|
|
23
|
-
this.minZoom = options.minZoom != undefined ? options.minZoom : 2;
|
|
24
|
-
|
|
25
|
-
this.maxZoom = options.maxZoom != undefined ? options.maxZoom : 17;
|
|
26
|
-
|
|
27
24
|
this.gridSizeByZoom = options.gridSizeByZoom || [
|
|
28
25
|
64, 32, 16, 8, 8, 8, 8, 16, 16, 16, 16, 16, 32, 16, 32, 16, 32, 16, 32, 16, 8, 4
|
|
29
26
|
];
|
|
30
27
|
|
|
28
|
+
"//{s}.srtm3.openglobus.org/{z}/{y}/{x}.ddm";
|
|
29
|
+
|
|
31
30
|
this.url =
|
|
32
31
|
options.url != undefined
|
|
33
32
|
? options.url
|
package/src/og/terrain/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BilTerrain } from './BilTerrain';
|
|
2
|
-
import { EmptyTerrain } from './EmptyTerrain';
|
|
3
|
-
import { GlobusTerrain } from './GlobusTerrain';
|
|
4
|
-
import { MapboxTerrain } from './MapboxTerrain';
|
|
1
|
+
import { BilTerrain } from './BilTerrain.js';
|
|
2
|
+
import { EmptyTerrain } from './EmptyTerrain.js';
|
|
3
|
+
import { GlobusTerrain } from './GlobusTerrain.js';
|
|
4
|
+
import { MapboxTerrain } from './MapboxTerrain.js';
|
|
5
5
|
|
|
6
6
|
export { EmptyTerrain, GlobusTerrain, MapboxTerrain, BilTerrain };
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
export function objParser(text){
|
|
2
|
+
const objPositions = [[0, 0, 0]];
|
|
3
|
+
const objTexcoords = [[0, 0]];
|
|
4
|
+
const objNormals = [[0, 0, 0]];
|
|
5
|
+
|
|
6
|
+
// same order as `f` indices
|
|
7
|
+
const objVertexData = [
|
|
8
|
+
objPositions,
|
|
9
|
+
objTexcoords,
|
|
10
|
+
objNormals,
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
// same order as `f` indices
|
|
14
|
+
let vertexData = [
|
|
15
|
+
[], // positions
|
|
16
|
+
[], // texcoords
|
|
17
|
+
[], // normals
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
const materialLibs = [];
|
|
21
|
+
const geometries = [];
|
|
22
|
+
let geometry;
|
|
23
|
+
let groups = ['default'];
|
|
24
|
+
let material = 'default';
|
|
25
|
+
let object = 'default';
|
|
26
|
+
|
|
27
|
+
const noop = () => {};
|
|
28
|
+
|
|
29
|
+
function newGeometry() {
|
|
30
|
+
// If there is an existing geometry and it's
|
|
31
|
+
// not empty then start a new one.
|
|
32
|
+
if (geometry && geometry.data.vertices.length) {
|
|
33
|
+
geometry = undefined;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function setGeometry() {
|
|
38
|
+
if (!geometry) {
|
|
39
|
+
const vertices = [];
|
|
40
|
+
const textures = [];
|
|
41
|
+
const normals = [];
|
|
42
|
+
vertexData = [
|
|
43
|
+
vertices,
|
|
44
|
+
textures,
|
|
45
|
+
normals,
|
|
46
|
+
];
|
|
47
|
+
geometry = {
|
|
48
|
+
object,
|
|
49
|
+
groups,
|
|
50
|
+
material,
|
|
51
|
+
data: {
|
|
52
|
+
vertices,
|
|
53
|
+
textures,
|
|
54
|
+
normals,
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
geometries.push(geometry);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function addVertex(vert) {
|
|
62
|
+
const ptn = vert.split('/');
|
|
63
|
+
ptn.forEach((objIndexStr, i) => {
|
|
64
|
+
if (!objIndexStr) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const objIndex = parseInt(objIndexStr);
|
|
68
|
+
const index = objIndex + (objIndex >= 0 ? 0 : objVertexData[i].length);
|
|
69
|
+
vertexData[i].push(...objVertexData[i][index]);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const keywords = {
|
|
74
|
+
v(parts) {
|
|
75
|
+
objPositions.push(parts.map(parseFloat));
|
|
76
|
+
},
|
|
77
|
+
vn(parts) {
|
|
78
|
+
objNormals.push(parts.map(parseFloat));
|
|
79
|
+
},
|
|
80
|
+
vt(parts) {
|
|
81
|
+
// should check for missing v and extra w?
|
|
82
|
+
objTexcoords.push(parts.map(parseFloat));
|
|
83
|
+
},
|
|
84
|
+
f(parts) {
|
|
85
|
+
setGeometry();
|
|
86
|
+
const numTriangles = parts.length - 2;
|
|
87
|
+
for (let tri = 0; tri < numTriangles; ++tri) {
|
|
88
|
+
addVertex(parts[0]);
|
|
89
|
+
addVertex(parts[tri + 1]);
|
|
90
|
+
addVertex(parts[tri + 2]);
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
s: noop, // smoothing group
|
|
94
|
+
mtllib(parts, unparsedArgs) {
|
|
95
|
+
// the spec says there can be multiple filenames here
|
|
96
|
+
// but many exist with spaces in a single filename
|
|
97
|
+
materialLibs.push(unparsedArgs);
|
|
98
|
+
},
|
|
99
|
+
usemtl(parts, unparsedArgs) {
|
|
100
|
+
material = unparsedArgs;
|
|
101
|
+
newGeometry();
|
|
102
|
+
},
|
|
103
|
+
g(parts) {
|
|
104
|
+
groups = parts;
|
|
105
|
+
newGeometry();
|
|
106
|
+
},
|
|
107
|
+
o(parts, unparsedArgs) {
|
|
108
|
+
object = unparsedArgs;
|
|
109
|
+
newGeometry();
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const keywordRE = /(\w*)(?: )*(.*)/;
|
|
114
|
+
const lines = text.split('\n');
|
|
115
|
+
for (let lineNo = 0; lineNo < lines.length; ++lineNo) {
|
|
116
|
+
const line = lines[lineNo].trim();
|
|
117
|
+
if (line === '' || line.startsWith('#')) {
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
const m = keywordRE.exec(line);
|
|
121
|
+
if (!m) {
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
const [, keyword, unparsedArgs] = m;
|
|
125
|
+
const parts = line.split(/\s+/).slice(1);
|
|
126
|
+
const handler = keywords[keyword];
|
|
127
|
+
if (!handler) {
|
|
128
|
+
console.warn('unhandled keyword:', keyword); // eslint-disable-line no-console
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
handler(parts, unparsedArgs);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// remove any arrays that have no entries.
|
|
135
|
+
for (const geometry of geometries) {
|
|
136
|
+
geometry.data = Object.fromEntries(
|
|
137
|
+
Object.entries(geometry.data).filter(([, array]) => array.length > 0));
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return {
|
|
141
|
+
geometries,
|
|
142
|
+
materialLibs,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export function transformLeftToRightCoordinateSystem(objData) {
|
|
147
|
+
const convertedGeometries = objData.geometries.map(geometry => {
|
|
148
|
+
const vertices = geometry.data.vertices;
|
|
149
|
+
const normals = geometry.data.normals;
|
|
150
|
+
const textures = geometry.data.textures;
|
|
151
|
+
rotateObject(geometry.data, 0)
|
|
152
|
+
const convertedVertices = [];
|
|
153
|
+
const convertedNormals = [];
|
|
154
|
+
const convertedTextures = [];
|
|
155
|
+
|
|
156
|
+
// Convert positions
|
|
157
|
+
for (let i = 0; i < vertices.length; i += 3) {
|
|
158
|
+
const x = vertices[i];
|
|
159
|
+
const y = vertices[i + 1];
|
|
160
|
+
const z = vertices[i + 2];
|
|
161
|
+
convertedVertices.push(x, y, z);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Convert normals
|
|
165
|
+
for (let i = 0; i < normals.length; i += 3) {
|
|
166
|
+
const x = normals[i];
|
|
167
|
+
const y = normals[i + 1];
|
|
168
|
+
const z = normals[i + 2];
|
|
169
|
+
convertedNormals.push(x, y, -z);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Convert textures
|
|
173
|
+
for (let i = 0; i < textures.length; i += 2) {
|
|
174
|
+
const s = textures[i];
|
|
175
|
+
const t = 1 - textures[i + 1];
|
|
176
|
+
convertedTextures.push(s, t);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return {
|
|
180
|
+
object: geometry.object,
|
|
181
|
+
groups: geometry.groups,
|
|
182
|
+
material: geometry.material,
|
|
183
|
+
data: {
|
|
184
|
+
vertices: convertedVertices,
|
|
185
|
+
normals: convertedNormals,
|
|
186
|
+
textures: convertedTextures
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
return {
|
|
192
|
+
geometries: convertedGeometries,
|
|
193
|
+
materialLibs: objData.materialLibs
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function rotateObject(obj, angle) {
|
|
198
|
+
const cosA = Math.cos(angle);
|
|
199
|
+
const sinA = Math.sin(angle);
|
|
200
|
+
|
|
201
|
+
const vertices = obj.vertices;
|
|
202
|
+
const normals = obj.normals;
|
|
203
|
+
|
|
204
|
+
for (let i = 0; i < vertices.length; i += 3) {
|
|
205
|
+
const x = vertices[i];
|
|
206
|
+
const y = vertices[i + 1];
|
|
207
|
+
const z = vertices[i + 2];
|
|
208
|
+
|
|
209
|
+
vertices[i] = x * cosA + z * sinA;
|
|
210
|
+
vertices[i + 1] = y;
|
|
211
|
+
vertices[i + 2] = -x * sinA + z * cosA;
|
|
212
|
+
|
|
213
|
+
const nx = normals[i];
|
|
214
|
+
const ny = normals[i + 1];
|
|
215
|
+
const nz = normals[i + 2];
|
|
216
|
+
|
|
217
|
+
normals[i] = nx * cosA + nz * sinA;
|
|
218
|
+
normals[i + 1] = ny;
|
|
219
|
+
normals[i + 2] = -nx * sinA + nz * cosA;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return {
|
|
223
|
+
vertices: vertices,
|
|
224
|
+
normals: normals
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
|
package/src/og/utils/shared.js
CHANGED
|
@@ -958,4 +958,13 @@ export async function loadImage(url) {
|
|
|
958
958
|
image.src = url;
|
|
959
959
|
return image;
|
|
960
960
|
});
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
/**
|
|
964
|
+
* Gets image is loaded
|
|
965
|
+
* @param {HTMLImageElement} image
|
|
966
|
+
* @returns {boolean} Returns true is the image is loaded
|
|
967
|
+
*/
|
|
968
|
+
export function isImageLoaded(image) {
|
|
969
|
+
return image.complete && image.naturalHeight !== 0;
|
|
961
970
|
}
|
package/src/og/webgl/Handler.js
CHANGED
|
@@ -291,7 +291,7 @@ class Handler {
|
|
|
291
291
|
/**
|
|
292
292
|
* Creates NEAREST filter texture.
|
|
293
293
|
* @public
|
|
294
|
-
* @param {
|
|
294
|
+
* @param {HTMLCanvasElement | Image} image - Image or Canvas object.
|
|
295
295
|
* @returns {Object} - WebGL texture object.
|
|
296
296
|
*/
|
|
297
297
|
createTexture_n_webgl1(image, internalFormat, texture) {
|
|
@@ -934,8 +934,6 @@ class Handler {
|
|
|
934
934
|
*/
|
|
935
935
|
start() {
|
|
936
936
|
if (!this._requestAnimationFrameId && this._initialized) {
|
|
937
|
-
this._lastAnimationFrameTime = window.performance.now();
|
|
938
|
-
this.defaultClock.setDate(new Date());
|
|
939
937
|
this._animationFrameCallback();
|
|
940
938
|
}
|
|
941
939
|
}
|
package/types/Globe.d.ts
CHANGED
|
@@ -43,6 +43,8 @@
|
|
|
43
43
|
* @param {Number} [options.minEqualZoomCameraSlope=0.8] - Minimal camera slope above te globe where segments on the screen bacame the same zoom level
|
|
44
44
|
* @param {Number} [options.loadingBatchSize=12] -
|
|
45
45
|
* @param {Number} [options.quadTreeStrategyPrototype] - Prototype of quadTree. QuadTreeStrategy for Earth is default.
|
|
46
|
+
* @param {Number} [options.msaa] - MSAA antialiasing parameter: 2,4,8,16. Default is 4.
|
|
47
|
+
* @param {Number} [options.dpi] - Device pixel ratio. Default is current screen DPI.
|
|
46
48
|
*/
|
|
47
49
|
export class Globe {
|
|
48
50
|
static set _staticCounter(arg: any);
|
package/types/LonLat.d.ts
CHANGED
|
@@ -20,6 +20,12 @@ export class LonLat {
|
|
|
20
20
|
* @returns {LonLat} -
|
|
21
21
|
*/
|
|
22
22
|
static createFromArray(arr: Array<number>): LonLat;
|
|
23
|
+
/**
|
|
24
|
+
* Create array from lonlat
|
|
25
|
+
* @param lonLat
|
|
26
|
+
* @returns {number[]}
|
|
27
|
+
*/
|
|
28
|
+
static toArray(lonLat: any): number[];
|
|
23
29
|
/**
|
|
24
30
|
* Converts degrees to mercator coordinates.
|
|
25
31
|
* @static
|
|
@@ -71,6 +77,11 @@ export class LonLat {
|
|
|
71
77
|
*/
|
|
72
78
|
public height: number;
|
|
73
79
|
isZero(): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Create array from lonlat
|
|
82
|
+
* @returns {number[]}
|
|
83
|
+
*/
|
|
84
|
+
toArray(): number[];
|
|
74
85
|
/**
|
|
75
86
|
* Sets coordinates.
|
|
76
87
|
* @public
|
|
@@ -88,7 +99,7 @@ export class LonLat {
|
|
|
88
99
|
*/
|
|
89
100
|
public copy(lonLat?: LonLat): LonLat;
|
|
90
101
|
/**
|
|
91
|
-
* Clone the
|
|
102
|
+
* Clone the coordinates.
|
|
92
103
|
* @public
|
|
93
104
|
* @returns {LonLat} -
|
|
94
105
|
*/
|
package/types/Object3d.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export class Object3d {
|
|
|
9
9
|
static createCylinder(radiusTop?: number, radiusBottom?: number, height?: number, radialSegments?: number, heightSegments?: number, isTop?: boolean, isBottom?: boolean, offsetX?: number, offsetY?: number, offsetZ?: number): Object3d;
|
|
10
10
|
static createCube(length?: number, height?: number, depth?: number, xOffset?: number, yOffset?: number, zOffset?: number): Object3d;
|
|
11
11
|
static createArrow(back?: number, height?: number, front?: number): Object3d;
|
|
12
|
+
static loadObj(src: any): Promise<any>;
|
|
12
13
|
constructor(data: any);
|
|
13
14
|
_name: any;
|
|
14
15
|
_vertices: any;
|
|
@@ -23,6 +24,7 @@ export class Object3d {
|
|
|
23
24
|
color: any[] | Float32Array;
|
|
24
25
|
_indices: any;
|
|
25
26
|
_normals: any;
|
|
27
|
+
set src(arg: string);
|
|
26
28
|
get src(): string;
|
|
27
29
|
get name(): any;
|
|
28
30
|
get vertices(): any;
|
package/types/Popup.d.ts
CHANGED
package/types/bv/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Box } from
|
|
2
|
-
import { Sphere } from
|
|
1
|
+
import { Box } from './Box.js';
|
|
2
|
+
import { Sphere } from './Sphere.js';
|
|
3
3
|
export { Box, Sphere };
|
|
@@ -68,13 +68,6 @@ export class PlanetCamera extends Camera {
|
|
|
68
68
|
* @type {quadTree.Node}
|
|
69
69
|
*/
|
|
70
70
|
protected _insideSegment: quadTree.Node;
|
|
71
|
-
/**
|
|
72
|
-
* Coordinates that depends on what segment class we are fling over.
|
|
73
|
-
* It can be WGS84 or Mercator coordinates. Gets in og.quadTree.Node
|
|
74
|
-
* @protected
|
|
75
|
-
* @type {LonLat}
|
|
76
|
-
*/
|
|
77
|
-
protected _insideSegmentPosition: LonLat;
|
|
78
71
|
slope: number;
|
|
79
72
|
_keyLock: Key;
|
|
80
73
|
_framesArr: any[];
|
package/types/camera/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Camera } from
|
|
2
|
-
import { PlanetCamera } from
|
|
1
|
+
import { Camera } from './Camera.js';
|
|
2
|
+
import { PlanetCamera } from './PlanetCamera.js';
|
|
3
3
|
export { Camera, PlanetCamera };
|
|
@@ -70,4 +70,4 @@ export class LayerAnimation extends Control {
|
|
|
70
70
|
_setCurrentIndexAsync(index: number, forceVisibility?: boolean, stopPropagation?: boolean): void;
|
|
71
71
|
}
|
|
72
72
|
import { Control } from "./Control.js";
|
|
73
|
-
import { Events } from
|
|
73
|
+
import { Events } from '../Events.js';
|
|
@@ -36,6 +36,6 @@ export class Lighting extends Control {
|
|
|
36
36
|
}
|
|
37
37
|
import { Control } from "./Control.js";
|
|
38
38
|
import { ToggleButton } from "../ui/ToggleButton.js";
|
|
39
|
-
import { Dialog } from
|
|
40
|
-
import { View } from
|
|
39
|
+
import { Dialog } from '../ui/Dialog.js';
|
|
40
|
+
import { View } from '../ui/View.js';
|
|
41
41
|
import { Slider } from "../ui/Slider.js";
|
package/types/control/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Control } from "./Control.js";
|
|
2
2
|
import { CompassButton } from "./CompassButton.js";
|
|
3
|
-
import { DebugInfo } from "./DebugInfo";
|
|
3
|
+
import { DebugInfo } from "./DebugInfo.js";
|
|
4
4
|
import { EarthNavigation } from "./EarthNavigation.js";
|
|
5
5
|
import { EarthCoordinates } from "./EarthCoordinates.js";
|
|
6
6
|
import { GeoImageDragControl } from "./GeoImageDragControl.js";
|
|
@@ -21,4 +21,5 @@ import { HeightRuler } from "./heightRuler/HeightRuler.js";
|
|
|
21
21
|
import { SimpleSkyBackground } from "./SimpleSkyBackground.js";
|
|
22
22
|
import { Selection } from "./selection/Selection.js";
|
|
23
23
|
import { LayerAnimation } from "./LayerAnimation.js";
|
|
24
|
-
|
|
24
|
+
import { TimelineControl } from "./timeline/TimelineControl.js";
|
|
25
|
+
export { Control, CompassButton, DebugInfo, EarthNavigation, EarthCoordinates, GeoImageDragControl, KeyboardNavigation, LayerSwitcher, MouseNavigation, ToggleWireframe, TouchNavigation, SimpleNavigation, ShowFps, ScaleControl, Sun, ZoomControl, MouseWheelZoomControl, Lighting, Ruler, HeightRuler, SimpleSkyBackground, Selection, LayerAnimation, TimelineControl };
|
|
@@ -37,6 +37,7 @@ export class RulerScene extends RenderNode {
|
|
|
37
37
|
_onCornerEnter(e: any): void;
|
|
38
38
|
_onCornerLeave(e: any): void;
|
|
39
39
|
_onLdblclick(): void;
|
|
40
|
+
setVisibility(visibility: any): void;
|
|
40
41
|
_onLclick(e: any): void;
|
|
41
42
|
_timeout: any;
|
|
42
43
|
_drawLine(startLonLat: any, endLonLat: any, startPos: any): void;
|
|
@@ -45,7 +46,7 @@ export class RulerScene extends RenderNode {
|
|
|
45
46
|
isCornersPositionChanged(): boolean;
|
|
46
47
|
get ellipsoid(): any;
|
|
47
48
|
}
|
|
48
|
-
import { RenderNode } from
|
|
49
|
-
import { Vec2 } from
|
|
50
|
-
import { Vector } from
|
|
51
|
-
import { Entity } from
|
|
49
|
+
import { RenderNode } from '../../scene/RenderNode.js';
|
|
50
|
+
import { Vec2 } from '../../math/Vec2.js';
|
|
51
|
+
import { Vector } from '../../layer/Vector.js';
|
|
52
|
+
import { Entity } from '../../entity/Entity.js';
|
|
@@ -28,6 +28,6 @@ export class SelectionScene extends RenderNode {
|
|
|
28
28
|
clear(): void;
|
|
29
29
|
get ellipsoid(): any;
|
|
30
30
|
}
|
|
31
|
-
import { RenderNode } from
|
|
32
|
-
import { Entity } from
|
|
33
|
-
import { Vector } from
|
|
31
|
+
import { RenderNode } from '../../scene/RenderNode.js';
|
|
32
|
+
import { Entity } from '../../entity/Entity.js';
|
|
33
|
+
import { Vector } from '../../layer/Vector.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export class TimelineControl extends Control {
|
|
2
|
+
constructor(options?: {});
|
|
3
|
+
_timelineView: TimelineView;
|
|
4
|
+
_toggleBtn: ToggleButton;
|
|
5
|
+
_dialog: Dialog;
|
|
6
|
+
}
|
|
7
|
+
import { Control } from '../Control.js';
|
|
8
|
+
import { TimelineView } from './TimelineView.js';
|
|
9
|
+
import { ToggleButton } from "../../ui/ToggleButton.js";
|
|
10
|
+
import { Dialog } from "../../ui/Dialog.js";
|