@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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openglobus/og",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.1",
|
|
4
4
|
"description": "[OpenGlobus](https://www.openglobus.org/) is a javascript library designed to display interactive 3d maps and planets with map tiles, imagery and vector data, markers and 3d objects. It uses the WebGL technology, open source and completely free.",
|
|
5
5
|
"directories": {
|
|
6
6
|
"example": "./sandbox"
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"style": "./css/og.css",
|
|
10
10
|
"types": "./types/index.d.ts",
|
|
11
11
|
"scripts": {
|
|
12
|
-
"
|
|
12
|
+
"docs": "jsdoc -r ./src/ -c ./jsdoc.conf.json -d ./docs",
|
|
13
13
|
"serve": "ws",
|
|
14
14
|
"build": "rollup -c --bundleConfigAsCjs",
|
|
15
15
|
"webgl": "rollup -c --environment entry:webgl",
|
|
@@ -44,25 +44,23 @@
|
|
|
44
44
|
"./css/og.css": "./css/og.css"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@babel/preset-env": "^7.
|
|
47
|
+
"@babel/preset-env": "^7.21.5",
|
|
48
48
|
"@rollup/plugin-json": "^6.0.0",
|
|
49
|
-
"@rollup/plugin-terser": "^0.4.
|
|
50
|
-
"@types/jest": "^29.
|
|
51
|
-
"
|
|
52
|
-
"
|
|
49
|
+
"@rollup/plugin-terser": "^0.4.1",
|
|
50
|
+
"@types/jest": "^29.5.1",
|
|
51
|
+
"clean-jsdoc-theme": "^4.2.7",
|
|
52
|
+
"eslint": "^8.39.0",
|
|
53
53
|
"jest": "^29.5.0",
|
|
54
|
-
"jest-canvas-mock": "^2.
|
|
54
|
+
"jest-canvas-mock": "^2.5.0",
|
|
55
55
|
"jest-environment-jsdom": "^29.5.0",
|
|
56
|
-
"jest-webgl-canvas-mock": "^0.2.3",
|
|
57
56
|
"jsdoc": "^4.0.2",
|
|
58
|
-
"lint-staged": "^13.
|
|
57
|
+
"lint-staged": "^13.2.2",
|
|
59
58
|
"local-web-server": "^5.3.0",
|
|
60
|
-
"postcss": "^8.4.
|
|
61
|
-
"prettier": "^2.8.
|
|
62
|
-
"rollup": "^3.
|
|
59
|
+
"postcss": "^8.4.23",
|
|
60
|
+
"prettier": "^2.8.8",
|
|
61
|
+
"rollup": "^3.21.3",
|
|
63
62
|
"rollup-plugin-postcss": "^4.0.2",
|
|
64
|
-
"
|
|
65
|
-
"typescript": "^4.9.5"
|
|
63
|
+
"typescript": "^5.0.4"
|
|
66
64
|
},
|
|
67
65
|
"lint-staged": {
|
|
68
66
|
"*.{js,ts}": [
|
package/src/og/Globe.js
CHANGED
|
@@ -71,6 +71,8 @@ const PLANET_NAME_PREFIX = "globus_planet_";
|
|
|
71
71
|
* @param {Number} [options.minEqualZoomCameraSlope=0.8] - Minimal camera slope above te globe where segments on the screen bacame the same zoom level
|
|
72
72
|
* @param {Number} [options.loadingBatchSize=12] -
|
|
73
73
|
* @param {Number} [options.quadTreeStrategyPrototype] - Prototype of quadTree. QuadTreeStrategy for Earth is default.
|
|
74
|
+
* @param {Number} [options.msaa] - MSAA antialiasing parameter: 2,4,8,16. Default is 4.
|
|
75
|
+
* @param {Number} [options.dpi] - Device pixel ratio. Default is current screen DPI.
|
|
74
76
|
*/
|
|
75
77
|
|
|
76
78
|
class Globe {
|
|
@@ -127,7 +129,7 @@ class Globe {
|
|
|
127
129
|
*/
|
|
128
130
|
this.renderer = new Renderer(
|
|
129
131
|
new Handler(_canvasId, {
|
|
130
|
-
pixelRatio: window.devicePixelRatio + 0.15,
|
|
132
|
+
pixelRatio: options.dpi || (window.devicePixelRatio + 0.15),
|
|
131
133
|
context: {
|
|
132
134
|
alpha: false,
|
|
133
135
|
antialias: false,
|
|
@@ -135,7 +137,8 @@ class Globe {
|
|
|
135
137
|
}
|
|
136
138
|
}), {
|
|
137
139
|
autoActivate: false,
|
|
138
|
-
backgroundColor: createColorRGB(options.backgroundColor, new Vec3(115 / 255, 203 / 255, 249 / 255))
|
|
140
|
+
backgroundColor: createColorRGB(options.backgroundColor, new Vec3(115 / 255, 203 / 255, 249 / 255)),
|
|
141
|
+
msaa: options.msaa
|
|
139
142
|
}
|
|
140
143
|
);
|
|
141
144
|
this.renderer.initialize();
|
package/src/og/LonLat.js
CHANGED
|
@@ -77,6 +77,23 @@ export class LonLat {
|
|
|
77
77
|
return new LonLat(arr[0], arr[1], arr[2]);
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
/**
|
|
81
|
+
* Create array from lonlat
|
|
82
|
+
* @param lonLat
|
|
83
|
+
* @returns {number[]}
|
|
84
|
+
*/
|
|
85
|
+
static toArray(lonLat) {
|
|
86
|
+
return [lonLat.lon, lonLat.lat, lonLat.height]
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Create array from lonlat
|
|
91
|
+
* @returns {number[]}
|
|
92
|
+
*/
|
|
93
|
+
toArray() {
|
|
94
|
+
return LonLat.toArray(this)
|
|
95
|
+
}
|
|
96
|
+
|
|
80
97
|
/**
|
|
81
98
|
* Converts degrees to mercator coordinates.
|
|
82
99
|
* @static
|
|
@@ -152,7 +169,7 @@ export class LonLat {
|
|
|
152
169
|
}
|
|
153
170
|
|
|
154
171
|
/**
|
|
155
|
-
* Clone the
|
|
172
|
+
* Clone the coordinates.
|
|
156
173
|
* @public
|
|
157
174
|
* @returns {LonLat} -
|
|
158
175
|
*/
|
package/src/og/Object3d.js
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
|
|
4
4
|
import { htmlColorToFloat32Array } from './utils/shared.js';
|
|
5
5
|
import { Vec3 } from './math/Vec3.js';
|
|
6
|
-
import {
|
|
6
|
+
import { MAX, MIN } from './math.js';
|
|
7
|
+
import { transformLeftToRightCoordinateSystem, objParser } from "./utils/objParser.js";
|
|
7
8
|
|
|
8
9
|
function getColor(color) {
|
|
9
10
|
if (color instanceof Array) {
|
|
@@ -44,7 +45,7 @@ class Object3d {
|
|
|
44
45
|
this._normals = data.normals || [];
|
|
45
46
|
} else {
|
|
46
47
|
this._normals = Object3d.getNormals(this._vertices);
|
|
47
|
-
this._indices = new Array(this._vertices.length/ 3);
|
|
48
|
+
this._indices = new Array(this._vertices.length / 3);
|
|
48
49
|
for (let i = 0, len = this._indices.length; i < len; i++) {
|
|
49
50
|
this._indices[i] = i;
|
|
50
51
|
}
|
|
@@ -78,6 +79,10 @@ class Object3d {
|
|
|
78
79
|
return this._src;
|
|
79
80
|
}
|
|
80
81
|
|
|
82
|
+
set src(src) {
|
|
83
|
+
this._src = src;
|
|
84
|
+
}
|
|
85
|
+
|
|
81
86
|
get name() {
|
|
82
87
|
return this._name;
|
|
83
88
|
}
|
|
@@ -371,6 +376,20 @@ class Object3d {
|
|
|
371
376
|
-7, 0, 6, 0, 0, front, 0, 0, back, 0, 0, back, 0, 0, front, 7, 0, 6]
|
|
372
377
|
});
|
|
373
378
|
}
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
static async loadObj(src) {
|
|
382
|
+
const obj = await fetch(src)
|
|
383
|
+
.then((response) => response.text())
|
|
384
|
+
.then((data) => transformLeftToRightCoordinateSystem(objParser(data)))
|
|
385
|
+
.catch(() => []);
|
|
386
|
+
|
|
387
|
+
return obj.geometries.map(({ data: { vertices, normals, textures } }) => new Object3d({
|
|
388
|
+
vertices,
|
|
389
|
+
normals,
|
|
390
|
+
texCoords: textures
|
|
391
|
+
}));
|
|
392
|
+
}
|
|
374
393
|
}
|
|
375
394
|
|
|
376
395
|
export { Object3d };
|
package/src/og/bv/index.js
CHANGED
|
@@ -59,7 +59,7 @@ class PlanetCamera extends Camera {
|
|
|
59
59
|
* @public
|
|
60
60
|
* @type {number}
|
|
61
61
|
*/
|
|
62
|
-
this.minAltitude = options.minAltitude ||
|
|
62
|
+
this.minAltitude = options.minAltitude || 1;
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
65
|
* Maximal alltitude that camera can reach over the globe.
|
|
@@ -103,14 +103,6 @@ class PlanetCamera extends Camera {
|
|
|
103
103
|
*/
|
|
104
104
|
this._insideSegment = null;
|
|
105
105
|
|
|
106
|
-
/**
|
|
107
|
-
* Coordinates that depends on what segment class we are fling over.
|
|
108
|
-
* It can be WGS84 or Mercator coordinates. Gets in og.quadTree.Node
|
|
109
|
-
* @protected
|
|
110
|
-
* @type {LonLat}
|
|
111
|
-
*/
|
|
112
|
-
this._insideSegmentPosition = new LonLat();
|
|
113
|
-
|
|
114
106
|
this.slope = 0;
|
|
115
107
|
|
|
116
108
|
this._keyLock = new Key();
|
|
@@ -146,6 +138,8 @@ class PlanetCamera extends Camera {
|
|
|
146
138
|
|
|
147
139
|
super.update();
|
|
148
140
|
|
|
141
|
+
this.updateGeodeticPosition();
|
|
142
|
+
|
|
149
143
|
this.eyeNorm = this.eye.normal();
|
|
150
144
|
this.slope = this._b.dot(this.eyeNorm);
|
|
151
145
|
|
|
@@ -632,7 +626,7 @@ class PlanetCamera extends Camera {
|
|
|
632
626
|
if (this._insideSegment && this._insideSegment.planet) {
|
|
633
627
|
this._terrainAltitude = this._insideSegment.getTerrainPoint(
|
|
634
628
|
this.eye,
|
|
635
|
-
this.
|
|
629
|
+
this._lonLatMerc,
|
|
636
630
|
this._terrainPoint
|
|
637
631
|
);
|
|
638
632
|
if (this._terrainAltitude < this.minAltitude && this._checkTerrainCollision) {
|
|
@@ -239,17 +239,18 @@ class LayerSwitcher extends Control {
|
|
|
239
239
|
if (
|
|
240
240
|
(nameConcat == 'TerrainProviders' && planet.terrain == object) ||
|
|
241
241
|
(nameConcat == 'BaseLayers' && planet.baseLayer == object) ||
|
|
242
|
-
(nameConcat == '
|
|
242
|
+
(nameConcat == 'Overlays' && object.getVisibility() == true)
|
|
243
243
|
) {
|
|
244
244
|
return true
|
|
245
245
|
}
|
|
246
|
+
return false
|
|
246
247
|
}
|
|
247
248
|
|
|
248
249
|
const createInput = (object, depth, type, nameConcat) => {
|
|
249
250
|
if (depth > 0) {
|
|
250
251
|
return elementFactory('input', {
|
|
251
|
-
class: 'og-layer-switcher-record-input ' +
|
|
252
|
-
|
|
252
|
+
class: 'og-layer-switcher-record-input ' + nameConcat,
|
|
253
|
+
type: type || 'checkbox',
|
|
253
254
|
...(visibility(object, nameConcat) ? { checked: true } : null)
|
|
254
255
|
}, '')
|
|
255
256
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import { ToggleButton } from "../ui/ToggleButton.js";
|
|
8
8
|
import { Control } from "./Control.js";
|
|
9
|
-
import {
|
|
9
|
+
import { HeightRuler } from "./heightRuler/HeightRuler.js";
|
|
10
10
|
|
|
11
11
|
const ICON_BUTTON_SVG = `<?xml version="1.0" encoding="iso-8859-1"?>
|
|
12
12
|
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
|
@@ -37,7 +37,7 @@ class RulerSwitcher extends Control {
|
|
|
37
37
|
...options
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
-
this.ruler = new
|
|
40
|
+
this.ruler = new HeightRuler({
|
|
41
41
|
ignoreTerrain: options.ignoreTerrain
|
|
42
42
|
});
|
|
43
43
|
}
|
|
@@ -9,12 +9,12 @@ import { Button } from "../ui/Button.js";
|
|
|
9
9
|
import { Control } from "./Control.js";
|
|
10
10
|
|
|
11
11
|
const ICON_PLUS_SVG = '<?xml version="1.0"?>' +
|
|
12
|
-
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">' +
|
|
12
|
+
'<svg width=24 height=24 xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">' +
|
|
13
13
|
' <path d="M 11 5 L 11 11 L 5 11 L 5 13 L 11 13 L 11 19 L 13 19 L 13 13 L 19 13 L 19 11 L 13 11 L 13 5 L 11 5 z"/>' +
|
|
14
14
|
'</svg>';
|
|
15
15
|
|
|
16
16
|
const ICON_MINUS_SVG = '<?xml version="1.0"?>' +
|
|
17
|
-
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">' +
|
|
17
|
+
'<svg width=24 height=24 xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">' +
|
|
18
18
|
' <path d="M 5 11 L 5 13 L 19 13 L 19 11 L 5 11 z"/>' +
|
|
19
19
|
'</svg>';
|
|
20
20
|
|
|
@@ -51,7 +51,11 @@ class HeightRulerScene extends RulerScene {
|
|
|
51
51
|
relativeToGround: false,
|
|
52
52
|
displayInLayerSwitcher: false
|
|
53
53
|
});
|
|
54
|
+
}
|
|
54
55
|
|
|
56
|
+
setVisibility(visibility) {
|
|
57
|
+
super.setVisibility(visibility);
|
|
58
|
+
this._geoRulerLayer.setVisibility(visibility);
|
|
55
59
|
}
|
|
56
60
|
|
|
57
61
|
get deltaLabel() {
|
|
@@ -115,7 +119,6 @@ class HeightRulerScene extends RulerScene {
|
|
|
115
119
|
}
|
|
116
120
|
|
|
117
121
|
_drawLine(startLonLat, endLonLat, startPos) {
|
|
118
|
-
|
|
119
122
|
super._drawLine(startLonLat, endLonLat, startPos);
|
|
120
123
|
this._updateHeightRaysAndLabels();
|
|
121
124
|
}
|
|
@@ -173,7 +176,8 @@ class HeightRulerScene extends RulerScene {
|
|
|
173
176
|
}
|
|
174
177
|
})
|
|
175
178
|
];
|
|
176
|
-
|
|
179
|
+
|
|
180
|
+
this._cornersLayer.setEntities(this._cornerEntity);
|
|
177
181
|
}
|
|
178
182
|
|
|
179
183
|
init() {
|
package/src/og/control/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CompassButton } from "./CompassButton.js";
|
|
2
2
|
import { Control } from "./Control.js";
|
|
3
|
-
import { DebugInfo } from "./DebugInfo";
|
|
3
|
+
import { DebugInfo } from "./DebugInfo.js";
|
|
4
4
|
import { EarthCoordinates } from "./EarthCoordinates.js";
|
|
5
5
|
import { EarthNavigation } from "./EarthNavigation.js";
|
|
6
6
|
import { GeoImageDragControl } from "./GeoImageDragControl.js";
|
|
@@ -22,6 +22,8 @@ import { ToggleWireframe } from "./ToggleWireframe.js";
|
|
|
22
22
|
import { TouchNavigation } from "./TouchNavigation.js";
|
|
23
23
|
import { ZoomControl } from "./ZoomControl.js";
|
|
24
24
|
|
|
25
|
+
import { TimelineControl } from "./timeline/TimelineControl.js";
|
|
26
|
+
|
|
25
27
|
export {
|
|
26
28
|
Control,
|
|
27
29
|
CompassButton,
|
|
@@ -45,5 +47,6 @@ export {
|
|
|
45
47
|
HeightRuler,
|
|
46
48
|
SimpleSkyBackground,
|
|
47
49
|
Selection,
|
|
48
|
-
LayerAnimation
|
|
50
|
+
LayerAnimation,
|
|
51
|
+
TimelineControl
|
|
49
52
|
};
|
|
@@ -19,6 +19,7 @@ export function distanceFormat(v) {
|
|
|
19
19
|
return `${v.toFixed(1)} m`;
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
+
|
|
22
23
|
let obj3d = Object3d.createCylinder(1.1, 0, 2.7, 20, 1, true, false, 0, 0, 0)
|
|
23
24
|
|
|
24
25
|
const LABEL_OPTIONS = {
|
|
@@ -65,6 +66,7 @@ class RulerScene extends RenderNode {
|
|
|
65
66
|
relativeToGround: true,
|
|
66
67
|
displayInLayerSwitcher: false
|
|
67
68
|
});
|
|
69
|
+
|
|
68
70
|
this._labelLayer = new Vector("ruler-label", {
|
|
69
71
|
entities: [],
|
|
70
72
|
pickingEnabled: false,
|
|
@@ -118,8 +120,6 @@ class RulerScene extends RenderNode {
|
|
|
118
120
|
'label': LABEL_OPTIONS
|
|
119
121
|
});
|
|
120
122
|
|
|
121
|
-
// this._propsLabel.label.setVisibility(false);
|
|
122
|
-
|
|
123
123
|
this._trackEntity = new Entity({
|
|
124
124
|
polyline: {
|
|
125
125
|
path3v: [],
|
|
@@ -133,7 +133,7 @@ class RulerScene extends RenderNode {
|
|
|
133
133
|
|
|
134
134
|
this._createCorners();
|
|
135
135
|
this._trackLayer.addEntities([this._trackEntity]);
|
|
136
|
-
this._labelLayer.addEntities([
|
|
136
|
+
this._labelLayer.addEntities([this._propsLabel]);
|
|
137
137
|
this._planet.addLayer(this._labelLayer);
|
|
138
138
|
this._planet.addLayer(this._trackLayer);
|
|
139
139
|
this._planet.addLayer(this._cornersLayer);
|
|
@@ -169,7 +169,7 @@ class RulerScene extends RenderNode {
|
|
|
169
169
|
this._onCornerLup_ = this._onCornerLup.bind(this);
|
|
170
170
|
this._cornersLayer.events.on("lup", this._onCornerLup, this);
|
|
171
171
|
|
|
172
|
-
|
|
172
|
+
this.setVisibility(false);
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
_deactivate() {
|
|
@@ -239,16 +239,19 @@ class RulerScene extends RenderNode {
|
|
|
239
239
|
this._preventClick = true;
|
|
240
240
|
}
|
|
241
241
|
|
|
242
|
+
setVisibility(visibility) {
|
|
243
|
+
this._cornersLayer.setVisibility(visibility);
|
|
244
|
+
this._trackLayer.setVisibility(visibility);
|
|
245
|
+
this._labelLayer.setVisibility(visibility);
|
|
246
|
+
}
|
|
247
|
+
|
|
242
248
|
_onLclick(e) {
|
|
243
249
|
let startLonLat = this._planet.getLonLatFromPixelTerrain(e);
|
|
244
250
|
this._timeout = setTimeout(() => {
|
|
245
251
|
if (!this._preventClick) {
|
|
246
252
|
if (!this._startLonLat) {
|
|
253
|
+
this.setVisibility(true);
|
|
247
254
|
this._stopDrawing = false;
|
|
248
|
-
this._propsLabel.setVisibility(false);
|
|
249
|
-
this._trackEntity.polyline.setPath3v([]);
|
|
250
|
-
this._cornerEntity[0].setVisibility(true);
|
|
251
|
-
this._cornerEntity[1].setVisibility(true);
|
|
252
255
|
this._startLonLat = startLonLat;
|
|
253
256
|
} else {
|
|
254
257
|
this._startLonLat = null;
|
|
@@ -26,12 +26,14 @@ class TimelineControl extends Control {
|
|
|
26
26
|
}
|
|
27
27
|
super(options);
|
|
28
28
|
|
|
29
|
-
let currentDate = new Date();
|
|
30
|
-
let startDate =
|
|
29
|
+
let currentDate = options.current || new Date();
|
|
30
|
+
let startDate = options.rangeStart || addHours(currentDate, -12);
|
|
31
|
+
let endDate = options.rangeEnd || addHours(currentDate, 12);
|
|
31
32
|
|
|
32
33
|
this._timelineView = new TimelineView({
|
|
33
34
|
rangeStart: startDate,
|
|
34
|
-
rangeEnd: endDate
|
|
35
|
+
rangeEnd: endDate,
|
|
36
|
+
current: currentDate
|
|
35
37
|
});
|
|
36
38
|
|
|
37
39
|
this._toggleBtn = new ToggleButton({
|
|
@@ -112,9 +112,7 @@ class TimelineView extends View {
|
|
|
112
112
|
this._playBtn = new ToggleButton({
|
|
113
113
|
classList: ["og-timeline-control_button"],
|
|
114
114
|
icon: ICON_PLAY_SVG,
|
|
115
|
-
name: "play"
|
|
116
|
-
isActive: true,
|
|
117
|
-
preventClick: true
|
|
115
|
+
name: "play"
|
|
118
116
|
});
|
|
119
117
|
|
|
120
118
|
this._buttons = new ButtonGroup({
|
|
@@ -183,6 +181,15 @@ class TimelineView extends View {
|
|
|
183
181
|
this._playBtn.appendTo(this.$controls);
|
|
184
182
|
this._pauseBtn.appendTo(this.$controls);
|
|
185
183
|
|
|
184
|
+
if (this.model.stopped()) {
|
|
185
|
+
this._pauseBtn.setActive(true, true);
|
|
186
|
+
this._pauseBtn.preventClick = true;
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
this._playBtn.setActive(true, true);
|
|
190
|
+
this._playBtn.preventClick = true;
|
|
191
|
+
}
|
|
192
|
+
|
|
186
193
|
this._buttons.on("change", (btn) => {
|
|
187
194
|
switch (btn.name) {
|
|
188
195
|
case "play":
|
|
@@ -268,8 +268,8 @@ class Segment {
|
|
|
268
268
|
* @param {Vec3} [normal] - Terrain point normal.
|
|
269
269
|
* @returns {Vec3} -
|
|
270
270
|
*/
|
|
271
|
-
getEntityTerrainPoint(entity, res
|
|
272
|
-
return this.getTerrainPoint(entity._cartesian, entity._lonlatMerc, res
|
|
271
|
+
getEntityTerrainPoint(entity, res) {
|
|
272
|
+
return this.getTerrainPoint(entity._cartesian, entity._lonlatMerc, res);
|
|
273
273
|
}
|
|
274
274
|
|
|
275
275
|
isEntityInside(e) {
|
|
@@ -285,80 +285,74 @@ class Segment {
|
|
|
285
285
|
* @param {Vec3} [normal] - Terrain point normal.
|
|
286
286
|
* @returns {number} -
|
|
287
287
|
*/
|
|
288
|
-
getTerrainPoint(xyz, insideSegmentPosition, res
|
|
289
|
-
|
|
288
|
+
getTerrainPoint(xyz, insideSegmentPosition, res) {
|
|
289
|
+
let verts = this.tempVertices;
|
|
290
290
|
|
|
291
|
-
|
|
291
|
+
if (verts && verts.length) {
|
|
292
|
+
let norm = this.planet.ellipsoid.getSurfaceNormal3v(xyz);
|
|
293
|
+
_ray.set(xyz, norm.negateTo());
|
|
292
294
|
|
|
293
|
-
|
|
294
|
-
var ne = this._extent.northEast,
|
|
295
|
+
let ne = this._extent.northEast,
|
|
295
296
|
sw = this._extent.southWest,
|
|
296
297
|
size = Math.sqrt(verts.length / 3) - 1;
|
|
297
298
|
|
|
298
|
-
|
|
299
|
+
let xmax = ne.lon,
|
|
299
300
|
ymax = ne.lat,
|
|
300
301
|
xmin = sw.lon,
|
|
301
302
|
ymin = sw.lat,
|
|
302
303
|
x = insideSegmentPosition.lon,
|
|
303
304
|
y = insideSegmentPosition.lat;
|
|
304
305
|
|
|
305
|
-
|
|
306
|
+
let sxn = xmax - xmin,
|
|
306
307
|
syn = ymax - ymin;
|
|
307
308
|
|
|
308
|
-
|
|
309
|
+
let qx = sxn / size,
|
|
309
310
|
qy = syn / size;
|
|
310
311
|
|
|
311
|
-
|
|
312
|
+
let xn = x - xmin,
|
|
312
313
|
yn = y - ymin;
|
|
313
314
|
|
|
314
|
-
|
|
315
|
+
let indX = Math.floor(xn / qx),
|
|
315
316
|
indY = Math.floor(size - yn / qy);
|
|
316
317
|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
var ind_v2 = ((size + 1) * (indY + 1) + indX) * 3;
|
|
318
|
+
let ind_v0 = ((size + 1) * indY + indX) * 3;
|
|
319
|
+
let ind_v2 = ((size + 1) * (indY + 1) + indX) * 3;
|
|
320
320
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
321
|
+
_v0.set(verts[ind_v0], verts[ind_v0 + 1], verts[ind_v0 + 2]);
|
|
322
|
+
_v1.set(verts[ind_v0 + 3], verts[ind_v0 + 4], verts[ind_v0 + 5]);
|
|
323
|
+
_v2.set(verts[ind_v2], verts[ind_v2 + 1], verts[ind_v2 + 2]);
|
|
324
324
|
|
|
325
|
-
|
|
325
|
+
let d = _ray.hitTriangle(_v0, _v1, _v2, res);
|
|
326
326
|
|
|
327
|
+
if (d === Ray.INSIDE) {
|
|
328
|
+
return xyz.distance(res);
|
|
329
|
+
} else if (d === Ray.AWAY) {
|
|
330
|
+
_rayEx.set(xyz, norm);
|
|
331
|
+
let d = _rayEx.hitTriangle(_v0, _v1, _v2, res);
|
|
327
332
|
if (d === Ray.INSIDE) {
|
|
328
|
-
return xyz.distance(res);
|
|
329
|
-
} else if (d === Ray.AWAY) {
|
|
330
|
-
_rayEx.set(xyz, xyz);
|
|
331
|
-
let d = _rayEx.hitTriangle(_v0, _v1, _v2, res, normal);
|
|
332
|
-
if (d === Ray.INSIDE) {
|
|
333
|
-
return -xyz.distance(res);
|
|
334
|
-
}
|
|
333
|
+
return -xyz.distance(res);
|
|
335
334
|
}
|
|
335
|
+
}
|
|
336
336
|
|
|
337
|
-
|
|
337
|
+
_v3.set(verts[ind_v2 + 3], verts[ind_v2 + 4], verts[ind_v2 + 5]);
|
|
338
338
|
|
|
339
|
-
|
|
339
|
+
d = _ray.hitTriangle(_v1, _v3, _v2, res);
|
|
340
|
+
if (d === Ray.INSIDE) {
|
|
341
|
+
return xyz.distance(res);
|
|
342
|
+
} else if (d === Ray.AWAY) {
|
|
343
|
+
_rayEx.set(xyz, norm);
|
|
344
|
+
let d = _rayEx.hitTriangle(_v1, _v3, _v2, res);
|
|
340
345
|
if (d === Ray.INSIDE) {
|
|
341
|
-
return xyz.distance(res);
|
|
342
|
-
} else if (d === Ray.AWAY) {
|
|
343
|
-
_rayEx.set(xyz, xyz);
|
|
344
|
-
let d = _rayEx.hitTriangle(_v1, _v3, _v2, res, normal);
|
|
345
|
-
if (d === Ray.INSIDE) {
|
|
346
|
-
return -xyz.distance(res);
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
if (d === Ray.AWAY) {
|
|
351
346
|
return -xyz.distance(res);
|
|
352
347
|
}
|
|
348
|
+
}
|
|
353
349
|
|
|
354
|
-
|
|
350
|
+
if (d === Ray.AWAY) {
|
|
351
|
+
return -xyz.distance(res);
|
|
355
352
|
}
|
|
356
353
|
|
|
357
|
-
res.copy(this.planet.ellipsoid.hitRay(_ray.origin, _ray.direction));
|
|
358
|
-
normal && normal.copy(xyz.normal());
|
|
359
354
|
return xyz.distance(res);
|
|
360
355
|
} else {
|
|
361
|
-
normal && normal.copy(xyz.normal());
|
|
362
356
|
return xyz.distance(this.planet.ellipsoid.hitRay(_ray.origin, _ray.direction));
|
|
363
357
|
}
|
|
364
358
|
}
|