@openglobus/og 0.14.4 → 0.15.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 +377 -274
- 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 +18 -17
- package/src/og/Clock.js +218 -194
- package/src/og/Globe.js +1 -3
- package/src/og/Object3d.js +104 -145
- package/src/og/camera/Camera.js +23 -19
- package/src/og/cons.js +107 -107
- package/src/og/control/Atmosphere.js +396 -0
- package/src/og/control/CompassButton.js +11 -18
- package/src/og/control/Control.js +187 -188
- package/src/og/control/GeoImageDragControl.js +84 -66
- package/src/og/control/LayerSwitcher.js +46 -145
- package/src/og/control/Lighting.js +314 -186
- package/src/og/control/RulerSwitcher.js +24 -19
- package/src/og/control/SimpleSkyBackground.js +38 -12
- package/src/og/control/Sun.js +2 -0
- package/src/og/control/ZoomControl.js +30 -42
- package/src/og/control/ruler/RulerScene.js +5 -23
- package/src/og/control/selection/Selection.js +21 -50
- package/src/og/control/selection/SelectionScene.js +15 -29
- package/src/og/control/timeline/TimelineControl.js +99 -0
- package/src/og/control/timeline/TimelineModel.js +133 -0
- package/src/og/control/timeline/TimelineView.js +449 -0
- package/src/og/control/timeline/timelineUtils.js +132 -0
- package/src/og/entity/Entity.js +30 -3
- package/src/og/entity/EntityCollection.js +0 -2
- package/src/og/entity/GeoObject.js +72 -56
- package/src/og/entity/GeoObjectHandler.js +487 -656
- package/src/og/input/input.js +3 -1
- package/src/og/layer/CanvasTiles.js +39 -34
- package/src/og/layer/Layer.js +2 -0
- package/src/og/layer/Material.js +1 -8
- package/src/og/light/LightSource.js +2 -0
- package/src/og/quadTree/Node.js +2 -1
- package/src/og/renderer/Renderer.js +26 -42
- package/src/og/renderer/RendererEvents.js +4 -4
- package/src/og/scene/Planet.js +276 -59
- package/src/og/scene/RenderNode.js +27 -12
- package/src/og/segment/Segment.js +0 -5
- package/src/og/shaders/atmos.js +332 -0
- package/src/og/shaders/drawnode.js +475 -109
- package/src/og/shaders/geoObject.js +96 -51
- package/src/og/shaders/polyline.js +212 -17
- package/src/og/shaders/utils.js +88 -0
- package/src/og/terrain/GlobusTerrain.js +2 -2
- package/src/og/ui/Button.js +106 -0
- package/src/og/ui/ButtonGroup.js +57 -0
- package/src/og/ui/Dialog.js +242 -0
- package/src/og/ui/Slider.js +144 -0
- package/src/og/ui/ToggleButton.js +51 -0
- package/src/og/ui/View.js +190 -0
- package/src/og/utils/shared.js +51 -33
- package/src/og/webgl/Framebuffer.js +308 -387
- package/src/og/webgl/Handler.js +68 -21
- package/src/og/webgl/Multisample.js +8 -0
- package/types/Clock.d.ts +7 -2
- package/types/Object3d.d.ts +14 -3
- package/types/camera/Camera.d.ts +15 -14
- package/types/control/Atmosphere.d.ts +15 -0
- package/types/control/CompassButton.d.ts +1 -2
- package/types/control/GeoImageDragControl.d.ts +7 -1
- package/types/control/LayerSwitcher.d.ts +4 -5
- package/types/control/Lighting.d.ts +32 -7
- package/types/control/SimpleSkyBackground.d.ts +4 -0
- package/types/control/ZoomControl.d.ts +0 -1
- package/types/control/ruler/RulerScene.d.ts +0 -1
- package/types/control/selection/Selection.d.ts +2 -4
- package/types/control/selection/SelectionScene.d.ts +0 -1
- package/types/entity/Entity.d.ts +8 -0
- package/types/entity/GeoObject.d.ts +28 -22
- package/types/entity/GeoObjectHandler.d.ts +16 -56
- package/types/input/input.d.ts +2 -0
- package/types/layer/CanvasTiles.d.ts +1 -0
- package/types/layer/Layer.d.ts +1 -0
- package/types/math/Plane.d.ts +1 -1
- package/types/renderer/Renderer.d.ts +7 -1
- package/types/scene/Planet.d.ts +20 -2
- package/types/scene/RenderNode.d.ts +2 -1
- package/types/segment/Segment.d.ts +1 -1
- package/types/shaders/atmos.d.ts +4 -0
- package/types/shaders/drawnode.d.ts +3 -2
- package/types/shaders/utils.d.ts +1 -0
- package/types/terrain/GlobusTerrain.d.ts +1 -1
- package/types/ui/Button.d.ts +21 -0
- package/types/ui/Dialog.d.ts +41 -0
- package/types/ui/Slider.d.ts +30 -0
- package/types/ui/ToggleButton.d.ts +10 -0
- package/types/ui/View.d.ts +32 -0
- package/types/utils/shared.d.ts +16 -14
- package/types/webgl/Framebuffer.d.ts +2 -5
- package/types/webgl/Handler.d.ts +11 -9
- package/types/webgl/Multisample.d.ts +2 -0
- package/src/og/ajax.js +0 -204
- package/src/og/entity/Object3d.js +0 -504
- package/types/ajax.d.ts +0 -24
- /package/src/og/{control → ui}/UIhelpers.js +0 -0
- /package/types/{control → ui}/UIhelpers.d.ts +0 -0
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import { Control } from "./Control.js";
|
|
8
8
|
import { Program } from '../webgl/Program.js';
|
|
9
|
+
import { htmlColorToRgb } from "../utils/shared.js";
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Frame per second(FPS) display control.
|
|
@@ -19,11 +20,28 @@ class SimpleSkyBackground extends Control {
|
|
|
19
20
|
name: "SimpleSkyBackground",
|
|
20
21
|
...options
|
|
21
22
|
});
|
|
23
|
+
|
|
24
|
+
this._colorOne = new Float32Array([1.0, 1.0, 1.0]);
|
|
25
|
+
this._colorTwo = new Float32Array([0.0, 153.0 / 255.0, 221.0 / 255.0]);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
set colorOne(htmlColor) {
|
|
29
|
+
let rgb = htmlColorToRgb(htmlColor);
|
|
30
|
+
this._colorOne[0] = rgb.x;
|
|
31
|
+
this._colorOne[1] = rgb.y;
|
|
32
|
+
this._colorOne[2] = rgb.z;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
set colorTwo(htmlColor) {
|
|
36
|
+
let rgb = htmlColorToRgb(htmlColor);
|
|
37
|
+
this._colorTwo[0] = rgb.x;
|
|
38
|
+
this._colorTwo[1] = rgb.y;
|
|
39
|
+
this._colorTwo[2] = rgb.z;
|
|
22
40
|
}
|
|
23
41
|
|
|
24
42
|
oninit() {
|
|
25
43
|
this.renderer.handler.addProgram(simpleSkyBackgroundShader());
|
|
26
|
-
this.
|
|
44
|
+
this.activate();
|
|
27
45
|
}
|
|
28
46
|
|
|
29
47
|
onactivate() {
|
|
@@ -44,13 +62,15 @@ class SimpleSkyBackground extends Control {
|
|
|
44
62
|
gl.disable(gl.DEPTH_TEST);
|
|
45
63
|
|
|
46
64
|
sh.activate();
|
|
47
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, this.renderer.
|
|
65
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, this.renderer.screenFramePositionBuffer);
|
|
48
66
|
gl.vertexAttribPointer(p.attributes.corners, 2, gl.FLOAT, false, 0, 0);
|
|
49
67
|
|
|
50
68
|
gl.uniform3fv(shu.camPos, [cam.eye.x, cam.eye.y, cam.eye.z]);
|
|
51
69
|
gl.uniform2fv(shu.iResolution, [h.getWidth(), h.getHeight()]);
|
|
52
70
|
gl.uniform1f(shu.fov, cam.getViewAngle());
|
|
53
71
|
gl.uniform1f(shu.earthRadius, this.planet.ellipsoid.getPolarSize() + 1);
|
|
72
|
+
gl.uniform3fv(shu.colorOne, this._colorOne);
|
|
73
|
+
gl.uniform3fv(shu.colorTwo, this._colorTwo);
|
|
54
74
|
|
|
55
75
|
gl.uniformMatrix4fv(shu.viewMatrix, false, cam._viewMatrix._m);
|
|
56
76
|
|
|
@@ -67,26 +87,29 @@ export function simpleSkyBackground(options) {
|
|
|
67
87
|
function simpleSkyBackgroundShader() {
|
|
68
88
|
return new Program("simpleSkyBackground", {
|
|
69
89
|
uniforms: {
|
|
70
|
-
iResolution: "vec2", fov: "float",
|
|
71
|
-
|
|
90
|
+
iResolution: "vec2", fov: "float",
|
|
91
|
+
camPos: "vec3",
|
|
92
|
+
earthRadius: "float",
|
|
93
|
+
viewMatrix: "mat4",
|
|
94
|
+
colorOne: "vec3",
|
|
95
|
+
colorTwo: "vec3"
|
|
72
96
|
}, attributes: {
|
|
73
97
|
corners: "vec3"
|
|
74
|
-
}, vertexShader:
|
|
75
|
-
|
|
98
|
+
}, vertexShader:
|
|
99
|
+
`attribute vec2 corners;
|
|
100
|
+
|
|
76
101
|
varying vec2 tc;
|
|
77
102
|
|
|
78
103
|
void main(void) {
|
|
79
104
|
gl_Position = vec4(corners, 0.0, 1.0);
|
|
80
105
|
tc = corners * 0.5 + 0.5;
|
|
81
|
-
}`, fragmentShader:
|
|
106
|
+
}`, fragmentShader:
|
|
107
|
+
`precision highp float;
|
|
82
108
|
|
|
83
109
|
#define MAX 10e10
|
|
84
110
|
#define PI 3.14159265359
|
|
85
111
|
#define rad(x) x * PI / 180.
|
|
86
|
-
#define ZERO vec3(0.0)
|
|
87
|
-
|
|
88
|
-
const vec3 START_COLOR = vec3(1.0);
|
|
89
|
-
const vec3 END_COLOR = vec3(0.0, 153.0/255.0, 221.0/255.0);
|
|
112
|
+
#define ZERO vec3(0.0)
|
|
90
113
|
|
|
91
114
|
#define RED vec4(1.0, 0.0, 0.0, 1.0)
|
|
92
115
|
#define GREEN vec4(0.0, 1.0, 0.0, 1.0)
|
|
@@ -96,6 +119,9 @@ function simpleSkyBackgroundShader() {
|
|
|
96
119
|
uniform float fov;
|
|
97
120
|
uniform float earthRadius;
|
|
98
121
|
uniform mat4 viewMatrix;
|
|
122
|
+
|
|
123
|
+
uniform vec3 colorOne;
|
|
124
|
+
uniform vec3 colorTwo;
|
|
99
125
|
|
|
100
126
|
varying vec2 tc;
|
|
101
127
|
|
|
@@ -176,7 +202,7 @@ function simpleSkyBackgroundShader() {
|
|
|
176
202
|
|
|
177
203
|
float maxI = sqrt(bigRadius * bigRadius + bigRadius * bigRadius);
|
|
178
204
|
|
|
179
|
-
gl_FragColor = vec4(mix(
|
|
205
|
+
gl_FragColor = vec4(mix(colorOne, colorTwo, Ix / maxI), 1.0);
|
|
180
206
|
}`
|
|
181
207
|
});
|
|
182
208
|
}
|
package/src/og/control/Sun.js
CHANGED
|
@@ -123,8 +123,10 @@ class Sun extends Control {
|
|
|
123
123
|
var tr = Vec3.proj_b_to_plane(cam._r, n, cam._r)
|
|
124
124
|
.normalize()
|
|
125
125
|
.scale(this.offsetHorizontal); // right
|
|
126
|
+
|
|
126
127
|
var d = tu.add(tr);
|
|
127
128
|
var pos = cam.eye.add(d);
|
|
129
|
+
|
|
128
130
|
if (this._k > 0) {
|
|
129
131
|
this._k -= 0.01;
|
|
130
132
|
let rot = Quat.getRotationBetweenVectors(
|
|
@@ -6,6 +6,17 @@
|
|
|
6
6
|
|
|
7
7
|
import { Control } from "./Control.js";
|
|
8
8
|
import { Key } from "../Lock.js";
|
|
9
|
+
import { Button } from "../ui/Button.js";
|
|
10
|
+
|
|
11
|
+
const ICON_PLUS_SVG = '<?xml version="1.0"?>' +
|
|
12
|
+
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">' +
|
|
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
|
+
'</svg>';
|
|
15
|
+
|
|
16
|
+
const ICON_MINUS_SVG = '<?xml version="1.0"?>' +
|
|
17
|
+
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">' +
|
|
18
|
+
' <path d="M 5 11 L 5 13 L 19 13 L 19 11 L 5 11 z"/>' +
|
|
19
|
+
'</svg>';
|
|
9
20
|
|
|
10
21
|
/**
|
|
11
22
|
* Planet zoom buttons control.
|
|
@@ -19,57 +30,34 @@ class ZoomControl extends Control {
|
|
|
19
30
|
|
|
20
31
|
this._keyLock = new Key();
|
|
21
32
|
|
|
22
|
-
this.planet = null;
|
|
23
|
-
|
|
24
33
|
this._move = 0;
|
|
25
34
|
}
|
|
26
35
|
|
|
27
36
|
oninit() {
|
|
28
|
-
var zoomDiv = document.createElement("div"),
|
|
29
|
-
btnZoomIn = document.createElement("button"),
|
|
30
|
-
btnZoomOut = document.createElement("button");
|
|
31
|
-
|
|
32
|
-
zoomDiv.className = "ogZoomControl";
|
|
33
|
-
btnZoomIn.className = "ogZoomButton ogZoomIn";
|
|
34
|
-
btnZoomOut.className = "ogZoomButton ogZoomOut";
|
|
35
|
-
|
|
36
|
-
zoomDiv.appendChild(btnZoomIn);
|
|
37
|
-
zoomDiv.appendChild(btnZoomOut);
|
|
38
|
-
|
|
39
|
-
this.renderer.div.appendChild(zoomDiv);
|
|
40
|
-
|
|
41
|
-
btnZoomIn.addEventListener("mousedown", (e) => this.zoomIn());
|
|
42
|
-
btnZoomIn.addEventListener("mouseup", (e) => this.stopZoom());
|
|
43
37
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
e.preventDefault();
|
|
49
|
-
this.zoomIn();
|
|
50
|
-
});
|
|
51
|
-
btnZoomIn.addEventListener("touchend", (e) => {
|
|
52
|
-
e.preventDefault();
|
|
53
|
-
this.stopZoom();
|
|
54
|
-
});
|
|
55
|
-
btnZoomIn.addEventListener("touchcancel", (e) => {
|
|
56
|
-
e.preventDefault();
|
|
57
|
-
this.stopZoom();
|
|
38
|
+
let zoomInBtn = new Button({
|
|
39
|
+
classList: ["og-map-button", "og-zoomin-button"],
|
|
40
|
+
icon: ICON_PLUS_SVG,
|
|
41
|
+
appendTo: this.renderer.div
|
|
58
42
|
});
|
|
59
43
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
btnZoomOut.addEventListener("touchend", (e) => {
|
|
65
|
-
e.preventDefault();
|
|
66
|
-
this.stopZoom();
|
|
67
|
-
});
|
|
68
|
-
btnZoomOut.addEventListener("touchcancel", (e) => {
|
|
69
|
-
e.preventDefault();
|
|
70
|
-
this.stopZoom();
|
|
44
|
+
let zoomOutBtn = new Button({
|
|
45
|
+
classList: ["og-map-button", "og-zoomout-button"],
|
|
46
|
+
icon: ICON_MINUS_SVG,
|
|
47
|
+
appendTo: this.renderer.div
|
|
71
48
|
});
|
|
72
49
|
|
|
50
|
+
zoomInBtn.on("mousedown", (e) => this.zoomIn());
|
|
51
|
+
zoomInBtn.on("mouseup", (e) => this.stopZoom());
|
|
52
|
+
zoomOutBtn.on("mousedown", (e) => this.zoomOut());
|
|
53
|
+
zoomOutBtn.on("mouseup", (e) => this.stopZoom());
|
|
54
|
+
zoomInBtn.on("touchstart", (e) => this.zoomIn());
|
|
55
|
+
zoomInBtn.on("touchend", (e) => this.stopZoom());
|
|
56
|
+
zoomInBtn.on("touchcancel", (e) => this.stopZoom());
|
|
57
|
+
zoomOutBtn.on("touchstart", (e) => this.zoomOut());
|
|
58
|
+
zoomOutBtn.on("touchend", (e) => this.stopZoom());
|
|
59
|
+
zoomOutBtn.on("touchcancel", (e) => this.stopZoom());
|
|
60
|
+
|
|
73
61
|
this.renderer.events.on("draw", this._draw, this);
|
|
74
62
|
}
|
|
75
63
|
|
|
@@ -13,11 +13,6 @@ import { Object3d } from '../../Object3d.js';
|
|
|
13
13
|
|
|
14
14
|
const OUTLINE_COUNT = 120;
|
|
15
15
|
|
|
16
|
-
const MAX_SCALE = 0.005;
|
|
17
|
-
const MIN_SCALE = 0.001;
|
|
18
|
-
const MAX_SCALE_HEIGHT = 3000.0;
|
|
19
|
-
const MIN_SCALE_HEIGHT = 19000000.0;
|
|
20
|
-
|
|
21
16
|
function distanceFormat(v) {
|
|
22
17
|
if (v > 1000) {
|
|
23
18
|
return `${(v / 1000).toFixed(1)} km`;
|
|
@@ -83,9 +78,7 @@ class RulerScene extends RenderNode {
|
|
|
83
78
|
instanced: true,
|
|
84
79
|
tag: "ruler",
|
|
85
80
|
color: "rgb(0,305,0)",
|
|
86
|
-
|
|
87
|
-
indices: obj3d.indexes,
|
|
88
|
-
normals: obj3d.normals
|
|
81
|
+
object3d: obj3d
|
|
89
82
|
},
|
|
90
83
|
properties: {
|
|
91
84
|
name: "start"
|
|
@@ -97,14 +90,11 @@ class RulerScene extends RenderNode {
|
|
|
97
90
|
instanced: true,
|
|
98
91
|
tag: "ruler",
|
|
99
92
|
color: "rgb(455,0,0)",
|
|
100
|
-
|
|
101
|
-
indices: obj3d.indexes,
|
|
102
|
-
normals: obj3d.normals
|
|
93
|
+
object3d: obj3d
|
|
103
94
|
},
|
|
104
95
|
properties: {
|
|
105
96
|
name: "end"
|
|
106
97
|
}
|
|
107
|
-
|
|
108
98
|
})
|
|
109
99
|
];
|
|
110
100
|
|
|
@@ -119,7 +109,9 @@ class RulerScene extends RenderNode {
|
|
|
119
109
|
this._cornersLayer = new Vector("corners", {
|
|
120
110
|
entities: [this._cornerEntity[0], this._cornerEntity[1]],
|
|
121
111
|
pickingEnabled: true,
|
|
122
|
-
displayInLayerSwitcher: false
|
|
112
|
+
displayInLayerSwitcher: false,
|
|
113
|
+
scaleByDistance: [100, 4000000, 1.0],
|
|
114
|
+
pickingScale: 2
|
|
123
115
|
});
|
|
124
116
|
}
|
|
125
117
|
|
|
@@ -308,22 +300,12 @@ class RulerScene extends RenderNode {
|
|
|
308
300
|
this._cornerEntity[1].geoObject.setVisibility(false);
|
|
309
301
|
}
|
|
310
302
|
|
|
311
|
-
getScale(cart) {
|
|
312
|
-
let r = this.renderer;
|
|
313
|
-
let t = 1.0 - (r.activeCamera._lonLat.height - MAX_SCALE_HEIGHT) / (MIN_SCALE_HEIGHT - MAX_SCALE_HEIGHT);
|
|
314
|
-
let _distanceToCamera = cart.distance(r.activeCamera.eye);
|
|
315
|
-
return math.lerp(t < 0 ? 0 : t, MAX_SCALE, MIN_SCALE) * _distanceToCamera;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
303
|
frame() {
|
|
319
304
|
let t = this._trackEntity.polyline.getPath3v()[0];
|
|
320
305
|
if (t) {
|
|
321
306
|
this._cornerEntity[0].setCartesian3v(t[0].clone());
|
|
322
307
|
this._cornerEntity[1].setCartesian3v(t[t.length - 1].clone());
|
|
323
308
|
|
|
324
|
-
this._cornerEntity[0].geoObject.setScale(this.getScale(this._cornerEntity[0].getCartesian()));
|
|
325
|
-
this._cornerEntity[1].geoObject.setScale(this.getScale(this._cornerEntity[1].getCartesian()));
|
|
326
|
-
|
|
327
309
|
if (!this._ignoreTerrain) {
|
|
328
310
|
let res = 0;
|
|
329
311
|
for (let i = 0, len = t.length - 1; i < len; i++) {
|
|
@@ -5,25 +5,25 @@
|
|
|
5
5
|
"use strict";
|
|
6
6
|
|
|
7
7
|
import { Control } from "../Control.js";
|
|
8
|
-
import { elementFactory, btnClickHandler } from "../UIhelpers.js";
|
|
9
8
|
import { SelectionScene } from "./SelectionScene.js";
|
|
9
|
+
import { ToggleButton } from "../../ui/ToggleButton.js";
|
|
10
10
|
|
|
11
|
+
const ICON_BUTTON_SVG = `<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
|
12
|
+
<svg width="800px" height="800px" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--gis" preserveAspectRatio="xMidYMid meet"><path d="M2.1 0v1.914H0v6h3V3h5.1V0h-6zm9 0v3h6V0h-6zm9 0v3h6V0h-6zm9 0v3h6V0h-6zm9 0v3h6V0h-6zm9 0v3h6V0h-6zm9 0v3h6V0h-6zm9 0v3h1.8v1.2h3V0h-4.8zm1.8 7.2v6h3v-6h-3zM0 10.913v6h3v-6H0zM66.9 16.2v6h3v-6h-3zM0 19.914v6h3v-6H0zM66.9 25.2v6h3v-6h-3zM0 28.914v6h3v-6H0zM66.9 34.2v6h3v-6h-3zM0 37.914v6h3v-6H0zM66.9 43.2v6h3v-6h-3zM0 46.914v6h3v-6H0zM66.9 52.2v6h3v-6h-3zM0 55.914v5.191h3.809v-3H3v-2.19H0zm6.809 2.191v3h6v-3h-6zm9 0v3h6v-3h-6zm9 0v3h6v-3h-6zm9 0v3h6v-3h-6zm9 0v3h6v-3h-6zm9 0v3h6v-3h-6zm9 0v3h6v-3h-6zm9.648 1.899a2.076 2.076 0 0 0-2.19 2.324l3.137 33.676c.2 1.635 2.135 2.399 3.397 1.34l6.623-5.371l2.969 5.142c1.707 2.958 4.417 3.684 7.375 1.977c2.957-1.708 3.684-4.417 1.976-7.375l-2.959-5.125l7.848-3.008c1.548-.564 1.855-2.62.539-3.611L71.576 60.416a2.073 2.073 0 0 0-1.119-.412z" fill="#000000"></path></svg>`;
|
|
11
13
|
|
|
12
14
|
/**
|
|
13
15
|
* Activate Selection
|
|
14
|
-
* @class
|
|
16
|
+
* @class
|
|
15
17
|
* @extends {Control}
|
|
16
18
|
* @param {Object} [options] - Control options.
|
|
17
|
-
* @param {Array} [options.activationIconClasses] - array with a list of classes to change the button icons
|
|
18
19
|
* @param {boolean} [options.ignoreTerrain=false].
|
|
19
20
|
* @param {function} options.onSelect - callback (extent) => {} where extent is selected extent array [minLon,minLat,maxLon,maxLat]
|
|
20
21
|
* @param {boolean} [options.autoSelectionHide=false] - clear selection rectangle after passing extent to callback
|
|
21
22
|
* @example:
|
|
22
|
-
* to use bootstrap icons, include
|
|
23
|
+
* to use bootstrap icons, include
|
|
23
24
|
* <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.2/font/bootstrap-icons.css">
|
|
24
|
-
*
|
|
25
|
+
*
|
|
25
26
|
* new Selection({
|
|
26
|
-
* activationIconClasses: ['bi', 'bi-bounding-box-circles'],
|
|
27
27
|
* ignoreTerrain: false,
|
|
28
28
|
* autoSelectionHide:true,
|
|
29
29
|
* onSelect: (extent) => {
|
|
@@ -54,17 +54,19 @@ import { SelectionScene } from "./SelectionScene.js";
|
|
|
54
54
|
class Selection extends Control {
|
|
55
55
|
constructor(options = {}) {
|
|
56
56
|
super(options);
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
|
|
59
58
|
this._selectorScene = new SelectionScene({
|
|
60
59
|
name: `selectionScene:${this._id}`,
|
|
61
60
|
ignoreTerrain: options.ignoreTerrain,
|
|
62
61
|
onSelect: options.onSelect,
|
|
63
62
|
autoSelectionHide: options.autoSelectionHide
|
|
64
63
|
});
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
this._toggleBtn = new ToggleButton({
|
|
67
|
+
classList: ["og-map-button", "og-selection_button"],
|
|
68
|
+
icon: ICON_BUTTON_SVG
|
|
69
|
+
});
|
|
68
70
|
}
|
|
69
71
|
|
|
70
72
|
set ignoreTerrain(v) {
|
|
@@ -72,20 +74,16 @@ class Selection extends Control {
|
|
|
72
74
|
}
|
|
73
75
|
|
|
74
76
|
oninit() {
|
|
75
|
-
this.
|
|
77
|
+
this._toggleBtn.appendTo(this.renderer.div);
|
|
76
78
|
|
|
79
|
+
this._toggleBtn.on("change", (isActive) => {
|
|
80
|
+
if (isActive) {
|
|
81
|
+
this.activate();
|
|
82
|
+
} else {
|
|
83
|
+
this.deactivate();
|
|
84
|
+
}
|
|
85
|
+
});
|
|
77
86
|
|
|
78
|
-
|
|
79
|
-
btnClickHandler('og-selection-menu-btn', null, null,
|
|
80
|
-
'#og-selection-menu-icon',
|
|
81
|
-
(off) => {
|
|
82
|
-
if (off){
|
|
83
|
-
this.deactivate();
|
|
84
|
-
} else {
|
|
85
|
-
this.activate();
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
|
|
89
87
|
this._selectorScene.bindPlanet(this.planet);
|
|
90
88
|
}
|
|
91
89
|
|
|
@@ -96,33 +94,6 @@ class Selection extends Control {
|
|
|
96
94
|
ondeactivate() {
|
|
97
95
|
this.renderer.removeNode(this._selectorScene);
|
|
98
96
|
}
|
|
99
|
-
|
|
100
|
-
createSelectorButton() {
|
|
101
|
-
let btnIcon =
|
|
102
|
-
elementFactory('div',
|
|
103
|
-
{id: 'og-selection-menu-icon', class: 'og-icon-holder'});
|
|
104
|
-
|
|
105
|
-
btnIcon.setAttribute("style", "font-size:24px; display: flex; justify-content: center; align-items: center; background: none !important");
|
|
106
|
-
|
|
107
|
-
if (this._activationIconClasses){
|
|
108
|
-
btnIcon.classList.add(... this._activationIconClasses);
|
|
109
|
-
} else {
|
|
110
|
-
let defaultIcon = document.createElement("span");
|
|
111
|
-
defaultIcon.setAttribute("style", "width: 24px;height: 24px;border: 1px solid black;");
|
|
112
|
-
btnIcon.appendChild(defaultIcon);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
let btn = elementFactory('div', {
|
|
116
|
-
id: 'og-selection-menu-btn',
|
|
117
|
-
class: 'og-geo-image-dragger og-menu-btn og-OFF'
|
|
118
|
-
},btnIcon);
|
|
119
|
-
|
|
120
|
-
btn.setAttribute("style", "top: 116px; right: 12px");
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
this.renderer.div.appendChild(btn);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
97
|
}
|
|
127
98
|
|
|
128
99
|
export { Selection };
|
|
@@ -79,11 +79,9 @@ class SelectionScene extends RenderNode {
|
|
|
79
79
|
geoObject: {
|
|
80
80
|
scale: 1,
|
|
81
81
|
instanced: true,
|
|
82
|
-
tag: "
|
|
82
|
+
tag: "selection",
|
|
83
83
|
color: "rgb(0,305,0)",
|
|
84
|
-
|
|
85
|
-
indices: obj3d.indexes,
|
|
86
|
-
normals: obj3d.normals
|
|
84
|
+
object3d: obj3d
|
|
87
85
|
},
|
|
88
86
|
properties: {
|
|
89
87
|
name: "start"
|
|
@@ -93,16 +91,13 @@ class SelectionScene extends RenderNode {
|
|
|
93
91
|
geoObject: {
|
|
94
92
|
scale: 1,
|
|
95
93
|
instanced: true,
|
|
96
|
-
tag: "
|
|
94
|
+
tag: "selection",
|
|
97
95
|
color: "rgb(455,0,0)",
|
|
98
|
-
|
|
99
|
-
indices: obj3d.indexes,
|
|
100
|
-
normals: obj3d.normals
|
|
96
|
+
object3d: obj3d
|
|
101
97
|
},
|
|
102
98
|
properties: {
|
|
103
99
|
name: "end"
|
|
104
100
|
}
|
|
105
|
-
|
|
106
101
|
})
|
|
107
102
|
];
|
|
108
103
|
|
|
@@ -117,7 +112,9 @@ class SelectionScene extends RenderNode {
|
|
|
117
112
|
this._cornersLayer = new Vector("corners", {
|
|
118
113
|
entities: [this._cornerEntity[0], this._cornerEntity[1]],
|
|
119
114
|
pickingEnabled: true,
|
|
120
|
-
displayInLayerSwitcher: false
|
|
115
|
+
displayInLayerSwitcher: false,
|
|
116
|
+
scaleByDistance: [1.0, 4000000, 0.01],
|
|
117
|
+
pickingScale: 2
|
|
121
118
|
});
|
|
122
119
|
}
|
|
123
120
|
|
|
@@ -153,6 +150,7 @@ class SelectionScene extends RenderNode {
|
|
|
153
150
|
this.renderer.events.on("lup", this._onMouseLup_, this);
|
|
154
151
|
|
|
155
152
|
this._planet.addLayer(this._trackLayer);
|
|
153
|
+
|
|
156
154
|
this._planet.addLayer(this._cornersLayer);
|
|
157
155
|
|
|
158
156
|
}
|
|
@@ -182,19 +180,17 @@ class SelectionScene extends RenderNode {
|
|
|
182
180
|
if (!this._startLonLat) {
|
|
183
181
|
|
|
184
182
|
|
|
185
|
-
|
|
186
183
|
this._propsLabel.label.setVisibility(false);
|
|
187
184
|
|
|
188
185
|
this._trackEntity.polyline.setPath3v([]);
|
|
189
186
|
|
|
190
187
|
|
|
191
|
-
|
|
192
188
|
this._cornerEntity[0].geoObject.setVisibility(true);
|
|
193
189
|
this._cornerEntity[1].geoObject.setVisibility(true);
|
|
194
190
|
|
|
195
191
|
this.renderer.controls.mouseNavigation.deactivate();
|
|
196
192
|
this._startLonLat = this._planet.getLonLatFromPixelTerrain(e);
|
|
197
|
-
|
|
193
|
+
|
|
198
194
|
let startPos = this._planet.ellipsoid.lonLatToCartesian(this._startLonLat);
|
|
199
195
|
this._cornerEntity[0].setCartesian3v(startPos);
|
|
200
196
|
this._cornerEntity[1].setCartesian3v(startPos);
|
|
@@ -207,6 +203,8 @@ class SelectionScene extends RenderNode {
|
|
|
207
203
|
this._pickedCorner = null;
|
|
208
204
|
this._anchorLonLat = null;
|
|
209
205
|
|
|
206
|
+
this._propsLabel.label.setVisibility(true);
|
|
207
|
+
|
|
210
208
|
if (this._onSelect && typeof this._onSelect === 'function') {
|
|
211
209
|
let startLonLat = this._cornerEntity[0].getLonLat();
|
|
212
210
|
let endLonLat = this._cornerEntity[1].getLonLat();
|
|
@@ -278,8 +276,8 @@ class SelectionScene extends RenderNode {
|
|
|
278
276
|
this._trackEntity.polyline.setPath3v([path]);
|
|
279
277
|
|
|
280
278
|
if (this._ignoreTerrain) {
|
|
281
|
-
//
|
|
282
|
-
//
|
|
279
|
+
// this._propsLabel.setCartesian3v(path[Math.floor(path.length / 2)]);
|
|
280
|
+
// this._propsLabel.label.setText(`${distanceFormat(length)}, ${Math.round(this._heading)} deg`);
|
|
283
281
|
}
|
|
284
282
|
}
|
|
285
283
|
|
|
@@ -299,30 +297,18 @@ class SelectionScene extends RenderNode {
|
|
|
299
297
|
this._cornerEntity[1].geoObject.setVisibility(false);
|
|
300
298
|
}
|
|
301
299
|
|
|
302
|
-
getScale(cart) {
|
|
303
|
-
let r = this.renderer;
|
|
304
|
-
let t = 1.0 - (r.activeCamera._lonLat.height - MAX_SCALE_HEIGHT) / (MIN_SCALE_HEIGHT - MAX_SCALE_HEIGHT);
|
|
305
|
-
let _distanceToCamera = cart.distance(r.activeCamera.eye);
|
|
306
|
-
return math.lerp(t < 0 ? 0 : t, MAX_SCALE, MIN_SCALE) * _distanceToCamera;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
300
|
frame() {
|
|
310
301
|
let t = this._trackEntity.polyline.getPath3v()[0];
|
|
311
302
|
if (t) {
|
|
312
|
-
this._cornerEntity[0].geoObject.setScale(this.getScale(this._cornerEntity[0].getCartesian()));
|
|
313
|
-
this._cornerEntity[1].geoObject.setScale(this.getScale(this._cornerEntity[1].getCartesian()));
|
|
314
|
-
|
|
315
303
|
if (!this._ignoreTerrain) {
|
|
316
304
|
let res = 0;
|
|
317
305
|
for (let i = 0, len = t.length - 1; i < len; i++) {
|
|
318
306
|
res += t[i + 1].distance(t[i]);
|
|
319
307
|
}
|
|
320
308
|
|
|
321
|
-
|
|
322
|
-
|
|
309
|
+
this._propsLabel.setCartesian3v(t[Math.floor(t.length / 2)]);
|
|
310
|
+
this._propsLabel.label.setText(`${distanceFormat(res)}, ${Math.round(this._heading)} deg`);
|
|
323
311
|
}
|
|
324
|
-
|
|
325
|
-
|
|
326
312
|
}
|
|
327
313
|
}
|
|
328
314
|
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
import { Control } from '../Control.js';
|
|
4
|
+
import { TimelineView } from './TimelineView.js';
|
|
5
|
+
import { Dialog } from "../../ui/Dialog.js";
|
|
6
|
+
import { ToggleButton } from "../../ui/ToggleButton.js";
|
|
7
|
+
import { UTCtoDate } from "../../astro/jd.js";
|
|
8
|
+
|
|
9
|
+
function addHours(date, hours) {
|
|
10
|
+
const temp = new Date(date);
|
|
11
|
+
temp.setHours(temp.getHours() + hours);
|
|
12
|
+
return temp;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const ICON_BUTTON_SVG = `<?xml version="1.0" encoding="utf-8"?>
|
|
16
|
+
<!-- Svg Vector Icons : http://www.onlinewebfonts.com/icon -->
|
|
17
|
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
18
|
+
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 1000 1000" enable-background="new 0 0 1000 1000" xml:space="preserve">
|
|
19
|
+
<metadata> Svg Vector Icons : http://www.onlinewebfonts.com/icon </metadata>
|
|
20
|
+
<g><path d="M500,10C229.4,10,10,229.4,10,500s219.4,490,490,490s490-219.4,490-490S770.6,10,500,10z M800.3,800.3c-39,39-84.5,69.7-135,91C613,913.5,557.4,924.7,500,924.7s-112.9-11.2-165.3-33.3c-50.5-21.3-95.9-52-135-91c-39-39-69.7-84.5-91-135C86.5,612.9,75.3,557.4,75.3,500s11.2-112.9,33.3-165.3c21.3-50.5,52-95.9,91-135c39-39,84.5-69.7,135-91C387.1,86.5,442.6,75.3,500,75.3s112.9,11.2,165.3,33.3c50.5,21.3,95.9,52,135,91c39,39,69.7,84.5,91,135c22.1,52.3,33.3,107.9,33.3,165.3s-11.2,112.9-33.3,165.3C869.9,715.8,839.3,761.2,800.3,800.3z"/><path d="M761.3,532.7H532.7V304c0-18.1-14.6-32.7-32.7-32.7s-32.7,14.6-32.7,32.7v261.3l0,0c0,18.1,14.6,32.7,32.7,32.7h261.3c18.1,0,32.7-14.6,32.7-32.7l0,0C794,547.3,779.4,532.7,761.3,532.7z"/></g>
|
|
21
|
+
</svg>`;
|
|
22
|
+
|
|
23
|
+
class TimelineControl extends Control {
|
|
24
|
+
constructor(options = {}) {
|
|
25
|
+
if (!options.name || options.name === "") {
|
|
26
|
+
options.name = "timeline";
|
|
27
|
+
}
|
|
28
|
+
super(options);
|
|
29
|
+
|
|
30
|
+
let currentDate = new Date();
|
|
31
|
+
let startDate = addHours(currentDate, -12), endDate = addHours(currentDate, 12);
|
|
32
|
+
|
|
33
|
+
this._timelineView = new TimelineView({
|
|
34
|
+
rangeStart: startDate,
|
|
35
|
+
rangeEnd: endDate
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
this._toggleBtn = new ToggleButton({
|
|
39
|
+
classList: ["og-map-button", "og-timeline_button"],
|
|
40
|
+
icon: ICON_BUTTON_SVG
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
this._dialog = new Dialog({
|
|
44
|
+
title: "Timeline",
|
|
45
|
+
visible: false,
|
|
46
|
+
resizable: true,
|
|
47
|
+
useHide: true,
|
|
48
|
+
top: 10,
|
|
49
|
+
left: 60,
|
|
50
|
+
width: 600,
|
|
51
|
+
height: 115,
|
|
52
|
+
minHeight: 115,
|
|
53
|
+
maxHeight: 110
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
this._dialog.on("visibility", (v) => {
|
|
57
|
+
this._toggleBtn.setActive(v);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
oninit() {
|
|
62
|
+
|
|
63
|
+
let $container = this.renderer.div;
|
|
64
|
+
|
|
65
|
+
this._toggleBtn.appendTo($container);
|
|
66
|
+
this._dialog.appendTo($container);
|
|
67
|
+
|
|
68
|
+
this._toggleBtn.on("change", (isActive) => {
|
|
69
|
+
this._dialog.setVisibility(isActive);
|
|
70
|
+
if (isActive) {
|
|
71
|
+
this._timelineView.resize();
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
this._timelineView.appendTo(this._dialog.container);
|
|
76
|
+
|
|
77
|
+
this._timelineView.on("setcurrent", (d) => {
|
|
78
|
+
this.renderer.handler.defaultClock.setDate(d);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
this._timelineView.on("startdrag", () => {
|
|
82
|
+
this.renderer.controls.mouseNavigation.deactivate();
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
this._timelineView.on("stopdrag", () => {
|
|
86
|
+
this.renderer.controls.mouseNavigation.activate();
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
this._timelineView.on("startdragcurrent", () => {
|
|
90
|
+
this.renderer.controls.mouseNavigation.deactivate();
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
this._timelineView.on("stopdragcurrent", () => {
|
|
94
|
+
this.renderer.controls.mouseNavigation.activate();
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export { TimelineControl };
|