@openglobus/og 0.14.10 → 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 +378 -275
- 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 +5 -5
- package/src/og/Object3d.js +104 -145
- package/src/og/camera/Camera.js +31 -27
- package/src/og/camera/PlanetCamera.js +22 -14
- 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 +56 -138
- package/src/og/control/Lighting.js +314 -186
- package/src/og/control/MouseNavigation.js +2 -2
- package/src/og/control/RulerSwitcher.js +24 -19
- package/src/og/control/ScaleControl.js +30 -10
- package/src/og/control/SimpleSkyBackground.js +210 -0
- package/src/og/control/Sun.js +2 -0
- package/src/og/control/ZoomControl.js +30 -42
- package/src/og/control/index.js +6 -0
- package/src/og/control/ruler/RulerScene.js +5 -23
- package/src/og/control/selection/Selection.js +99 -0
- package/src/og/control/selection/SelectionScene.js +350 -0
- 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/ellipsoid/Ellipsoid.js +120 -93
- package/src/og/ellipsoid/wgs84.js +13 -13
- package/src/og/entity/Entity.js +36 -9
- 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/entity/GeometryHandler.js +1341 -1337
- package/src/og/entity/Polyline.js +0 -16
- package/src/og/entity/Ray.js +0 -10
- package/src/og/entity/RayHandler.js +3 -44
- package/src/og/entity/Strip.js +1 -6
- package/src/og/index.js +10 -6
- package/src/og/input/input.js +3 -1
- package/src/og/layer/CanvasTiles.js +39 -34
- package/src/og/layer/Layer.js +69 -9
- package/src/og/layer/Material.js +1 -8
- package/src/og/layer/WMS.js +16 -5
- package/src/og/light/LightSource.js +2 -0
- package/src/og/math/Line3.js +140 -139
- package/src/og/math/Plane.js +118 -117
- package/src/og/math/Ray.js +242 -239
- package/src/og/math/Vec3.js +56 -37
- package/src/og/math/Vec4.js +3 -4
- package/src/og/math.js +21 -21
- package/src/og/quadTree/Node.js +5 -4
- package/src/og/quadTree/index.js +12 -0
- package/src/og/renderer/Renderer.js +64 -37
- package/src/og/renderer/RendererEvents.js +1071 -1065
- package/src/og/scene/Planet.js +352 -172
- 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/ray.js +13 -6
- package/src/og/shaders/toneMapping.js +5 -5
- package/src/og/shaders/utils.js +88 -0
- package/src/og/terrain/GlobusTerrain.js +5 -4
- package/src/og/terrain/MapboxTerrain.js +231 -52
- 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/{control → ui}/UIhelpers.js +11 -2
- package/src/og/ui/View.js +190 -0
- package/src/og/utils/shared.js +960 -942
- package/src/og/webgl/Framebuffer.js +308 -387
- package/src/og/webgl/Handler.js +90 -30
- 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 +18 -17
- package/types/camera/PlanetCamera.d.ts +3 -1
- 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 +5 -6
- package/types/control/Lighting.d.ts +32 -7
- package/types/control/ScaleControl.d.ts +2 -1
- package/types/control/SimpleSkyBackground.d.ts +15 -0
- package/types/control/ZoomControl.d.ts +0 -1
- package/types/control/index.d.ts +4 -1
- package/types/control/ruler/RulerScene.d.ts +0 -1
- package/types/control/selection/Selection.d.ts +49 -0
- package/types/control/selection/SelectionScene.d.ts +34 -0
- package/types/ellipsoid/Ellipsoid.d.ts +3 -2
- 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/entity/Ray.d.ts +0 -3
- package/types/entity/RayHandler.d.ts +0 -4
- package/types/index.d.ts +7 -5
- package/types/input/input.d.ts +2 -0
- package/types/layer/CanvasTiles.d.ts +1 -0
- package/types/layer/Layer.d.ts +9 -0
- package/types/layer/WMS.d.ts +7 -3
- package/types/math/Plane.d.ts +1 -1
- package/types/math/Vec3.d.ts +19 -16
- package/types/math/Vec4.d.ts +2 -3
- package/types/math.d.ts +20 -20
- package/types/quadTree/index.d.ts +10 -0
- package/types/renderer/Renderer.d.ts +11 -37
- package/types/scene/Planet.d.ts +27 -1
- 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/terrain/MapboxTerrain.d.ts +2 -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/{control → ui}/UIhelpers.d.ts +1 -1
- 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 +15 -10
- package/types/webgl/Multisample.d.ts +2 -0
- package/src/og/ajax.js +0 -204
- package/src/og/entity/Object3d.js +0 -504
- package/src/og/utils/quadTreeType.js +0 -11
- package/types/ajax.d.ts +0 -24
- package/types/utils/quadTreeType.d.ts +0 -8
|
@@ -6,7 +6,23 @@
|
|
|
6
6
|
|
|
7
7
|
import { Control } from "./Control.js";
|
|
8
8
|
import { Ruler } from "./ruler/Ruler.js";
|
|
9
|
-
import {
|
|
9
|
+
import { ToggleButton } from "../ui/ToggleButton.js";
|
|
10
|
+
|
|
11
|
+
const ICON_BUTTON_SVG = `<?xml version="1.0" encoding="iso-8859-1"?>
|
|
12
|
+
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
|
13
|
+
<svg fill="#000000" height="800px" width="800px" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
14
|
+
\t viewBox="0 0 512 512" xml:space="preserve">
|
|
15
|
+
<g>
|
|
16
|
+
\t<g>
|
|
17
|
+
\t\t<path d="M369.151,0L0.001,369.15L142.85,512l369.149-369.15L369.151,0z M47.286,369.15l10.908-10.908l47.782,47.782l23.642-23.642
|
|
18
|
+
\t\t\tL81.837,334.6l10.909-10.909l23.711,23.711L140.1,323.76l-23.711-23.711l10.909-10.909l23.711,23.711l23.642-23.642
|
|
19
|
+
\t\t\tl-23.711-23.711l10.909-10.909l47.782,47.782l23.642-23.642l-47.782-47.782l10.908-10.908l23.71,23.71l23.642-23.642l-23.71-23.71
|
|
20
|
+
\t\t\tl10.908-10.908l23.711,23.711l23.642-23.642l-23.711-23.711l10.909-10.909l47.782,47.782l23.642-23.642l-47.782-47.782
|
|
21
|
+
\t\t\tl10.908-10.908l23.71,23.711l23.642-23.642l-23.711-23.71L334.6,81.837l23.711,23.71l23.642-23.642l-23.711-23.712l10.908-10.908
|
|
22
|
+
\t\t\tl95.564,95.564L142.85,464.714L47.286,369.15z"/>
|
|
23
|
+
\t</g>
|
|
24
|
+
</g>
|
|
25
|
+
</svg>`;
|
|
10
26
|
|
|
11
27
|
/**
|
|
12
28
|
* Activate ruler
|
|
@@ -37,31 +53,20 @@ class RulerSwitcher extends Control {
|
|
|
37
53
|
}
|
|
38
54
|
|
|
39
55
|
_createMenuBtn() {
|
|
40
|
-
let btn = elementFactory(
|
|
41
|
-
'div',
|
|
42
|
-
{ id: 'og-ruler-menu-btn', class: 'og-ruler og-menu-btn og-OFF' },
|
|
43
|
-
elementFactory(
|
|
44
|
-
'div',
|
|
45
|
-
{ id: 'og-ruler-menu-icon', class: 'og-icon-holder' }
|
|
46
|
-
)
|
|
47
|
-
);
|
|
48
56
|
|
|
49
|
-
|
|
57
|
+
let btn = new ToggleButton({
|
|
58
|
+
classList: ["og-map-button", "og-ruler_button"],
|
|
59
|
+
icon: ICON_BUTTON_SVG,
|
|
60
|
+
appendTo: this.renderer.div
|
|
61
|
+
});
|
|
50
62
|
|
|
51
|
-
btn.
|
|
52
|
-
if (
|
|
63
|
+
btn.on("change", (isActive) => {
|
|
64
|
+
if (isActive) {
|
|
53
65
|
this.onactivate();
|
|
54
66
|
} else {
|
|
55
67
|
this.ondeactivate();
|
|
56
68
|
}
|
|
57
69
|
});
|
|
58
|
-
|
|
59
|
-
btnClickHandler(
|
|
60
|
-
btn,
|
|
61
|
-
null,
|
|
62
|
-
null,
|
|
63
|
-
'#og-ruler-menu-icon'
|
|
64
|
-
);
|
|
65
70
|
}
|
|
66
71
|
}
|
|
67
72
|
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import { Control } from "./Control.js";
|
|
8
8
|
import { RADIANS } from "../math.js";
|
|
9
9
|
import { binarySearch, parseHTML } from "../utils/shared.js";
|
|
10
|
+
import { Vec3 } from "../math/Vec3.js";
|
|
10
11
|
|
|
11
12
|
const scale = [
|
|
12
13
|
1, 2, 3, 5, 10, 20, 30, 50, 100, 200, 300, 500, 1e3, 2e3, 3e3, 5e3, 10e3, 20e3, 30e3, 50e3,
|
|
@@ -38,6 +39,8 @@ class ScaleControl extends Control {
|
|
|
38
39
|
|
|
39
40
|
this._minWidth = 100;
|
|
40
41
|
this._maxWidth = 150;
|
|
42
|
+
|
|
43
|
+
this._isCenter = options.isCenter || false;
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
_renderTemplate() {
|
|
@@ -51,21 +54,38 @@ class ScaleControl extends Control {
|
|
|
51
54
|
|
|
52
55
|
this.renderer.div.appendChild(this.el);
|
|
53
56
|
|
|
54
|
-
this.
|
|
55
|
-
|
|
56
|
-
this.
|
|
57
|
-
}
|
|
58
|
-
});
|
|
57
|
+
if (this._isCenter) {
|
|
58
|
+
this.renderer.activeCamera.events.on("moveend", (e) => {
|
|
59
|
+
this._drawScreen(this.planet.renderer.handler.getCenter());
|
|
60
|
+
});
|
|
59
61
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
this.planet.terrain.events.on("loadend", (e) => {
|
|
63
|
+
this._drawScreen(this.planet.renderer.handler.getCenter());
|
|
64
|
+
});
|
|
65
|
+
} else {
|
|
66
|
+
this.renderer.events.on("mousemove", (e) => {
|
|
67
|
+
if (!e.leftButtonHold && !e.rightButtonHold) {
|
|
68
|
+
this._drawScreen(e);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
this.renderer.activeCamera.events.on("moveend", (e) => {
|
|
73
|
+
let ms = this.renderer.events.mouseState;
|
|
74
|
+
if (!ms.leftButtonHold && !ms.rightButtonHold) {
|
|
75
|
+
this._drawScreen(ms);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
63
79
|
}
|
|
64
80
|
|
|
65
|
-
|
|
81
|
+
_drawScreen(px) {
|
|
66
82
|
let cam = this.renderer.activeCamera;
|
|
67
|
-
let s0 =
|
|
83
|
+
let s0 = px;
|
|
68
84
|
let dist = this.planet.getDistanceFromPixel(s0);
|
|
85
|
+
if (dist === 0) {
|
|
86
|
+
s0 = cam.project(Vec3.ZERO);
|
|
87
|
+
dist = this.planet.getDistanceFromPixel(s0);
|
|
88
|
+
}
|
|
69
89
|
let p0 = cam.getForward().scaleTo(dist).addA(cam.eye);
|
|
70
90
|
let tempSize = dist * Math.tan(cam._viewAngle * RADIANS);
|
|
71
91
|
let p1 = p0.add(cam.getRight().scaleTo(tempSize));
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module og/control/SimpleSkyBackground
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
import { Control } from "./Control.js";
|
|
8
|
+
import { Program } from '../webgl/Program.js';
|
|
9
|
+
import { htmlColorToRgb } from "../utils/shared.js";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Frame per second(FPS) display control.
|
|
13
|
+
* @class
|
|
14
|
+
* @extends {Control}
|
|
15
|
+
* @param {Object} [options] - Control options.
|
|
16
|
+
*/
|
|
17
|
+
class SimpleSkyBackground extends Control {
|
|
18
|
+
constructor(options) {
|
|
19
|
+
super({
|
|
20
|
+
name: "SimpleSkyBackground",
|
|
21
|
+
...options
|
|
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;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
oninit() {
|
|
43
|
+
this.renderer.handler.addProgram(simpleSkyBackgroundShader());
|
|
44
|
+
this.activate();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
onactivate() {
|
|
48
|
+
super.onactivate();
|
|
49
|
+
this.planet.events.on("draw", this._drawBackground, this);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
ondeactivate() {
|
|
53
|
+
super.ondeactivate();
|
|
54
|
+
this.planet.events.off("draw", this._drawBackground);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
_drawBackground() {
|
|
58
|
+
let h = this.renderer.handler;
|
|
59
|
+
let sh = h.programs.simpleSkyBackground, p = sh._program, shu = p.uniforms, gl = h.gl;
|
|
60
|
+
let cam = this.renderer.activeCamera;
|
|
61
|
+
|
|
62
|
+
gl.disable(gl.DEPTH_TEST);
|
|
63
|
+
|
|
64
|
+
sh.activate();
|
|
65
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, this.renderer.screenFramePositionBuffer);
|
|
66
|
+
gl.vertexAttribPointer(p.attributes.corners, 2, gl.FLOAT, false, 0, 0);
|
|
67
|
+
|
|
68
|
+
gl.uniform3fv(shu.camPos, [cam.eye.x, cam.eye.y, cam.eye.z]);
|
|
69
|
+
gl.uniform2fv(shu.iResolution, [h.getWidth(), h.getHeight()]);
|
|
70
|
+
gl.uniform1f(shu.fov, cam.getViewAngle());
|
|
71
|
+
gl.uniform1f(shu.earthRadius, this.planet.ellipsoid.getPolarSize() + 1);
|
|
72
|
+
gl.uniform3fv(shu.colorOne, this._colorOne);
|
|
73
|
+
gl.uniform3fv(shu.colorTwo, this._colorTwo);
|
|
74
|
+
|
|
75
|
+
gl.uniformMatrix4fv(shu.viewMatrix, false, cam._viewMatrix._m);
|
|
76
|
+
|
|
77
|
+
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
|
|
78
|
+
|
|
79
|
+
gl.enable(gl.DEPTH_TEST);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function simpleSkyBackground(options) {
|
|
84
|
+
return new SimpleSkyBackground(options);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function simpleSkyBackgroundShader() {
|
|
88
|
+
return new Program("simpleSkyBackground", {
|
|
89
|
+
uniforms: {
|
|
90
|
+
iResolution: "vec2", fov: "float",
|
|
91
|
+
camPos: "vec3",
|
|
92
|
+
earthRadius: "float",
|
|
93
|
+
viewMatrix: "mat4",
|
|
94
|
+
colorOne: "vec3",
|
|
95
|
+
colorTwo: "vec3"
|
|
96
|
+
}, attributes: {
|
|
97
|
+
corners: "vec3"
|
|
98
|
+
}, vertexShader:
|
|
99
|
+
`attribute vec2 corners;
|
|
100
|
+
|
|
101
|
+
varying vec2 tc;
|
|
102
|
+
|
|
103
|
+
void main(void) {
|
|
104
|
+
gl_Position = vec4(corners, 0.0, 1.0);
|
|
105
|
+
tc = corners * 0.5 + 0.5;
|
|
106
|
+
}`, fragmentShader:
|
|
107
|
+
`precision highp float;
|
|
108
|
+
|
|
109
|
+
#define MAX 10e10
|
|
110
|
+
#define PI 3.14159265359
|
|
111
|
+
#define rad(x) x * PI / 180.
|
|
112
|
+
#define ZERO vec3(0.0)
|
|
113
|
+
|
|
114
|
+
#define RED vec4(1.0, 0.0, 0.0, 1.0)
|
|
115
|
+
#define GREEN vec4(0.0, 1.0, 0.0, 1.0)
|
|
116
|
+
|
|
117
|
+
uniform vec3 camPos;
|
|
118
|
+
uniform vec2 iResolution;
|
|
119
|
+
uniform float fov;
|
|
120
|
+
uniform float earthRadius;
|
|
121
|
+
uniform mat4 viewMatrix;
|
|
122
|
+
|
|
123
|
+
uniform vec3 colorOne;
|
|
124
|
+
uniform vec3 colorTwo;
|
|
125
|
+
|
|
126
|
+
varying vec2 tc;
|
|
127
|
+
|
|
128
|
+
// compute the view ray in the camera coordinate
|
|
129
|
+
vec3 computeView(vec2 uv){
|
|
130
|
+
float w_h_ratio = iResolution.x / iResolution.y;
|
|
131
|
+
float h = tan(rad(fov/2.));
|
|
132
|
+
return normalize(vec3(-w_h_ratio * h, -h, -1.) + vec3(uv.x * 2. * h * w_h_ratio, uv.y*2.*h, 0.));
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// sphere of size ra centered at point ce
|
|
136
|
+
vec2 sphIntersect( in vec3 ro, in vec3 rd, in vec3 ce, float ra )
|
|
137
|
+
{
|
|
138
|
+
vec3 oc = ro - ce;
|
|
139
|
+
float b = dot( oc, rd );
|
|
140
|
+
float c = dot( oc, oc ) - ra * ra;
|
|
141
|
+
float h = b * b - c;
|
|
142
|
+
if( h < 0.0 ) return vec2(MAX); // no intersection
|
|
143
|
+
h = sqrt( h );
|
|
144
|
+
return vec2( -b-h, -b+h );
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
mat3 transpose(mat3 matrix) {
|
|
148
|
+
vec3 row0 = matrix[0];
|
|
149
|
+
vec3 row1 = matrix[1];
|
|
150
|
+
vec3 row2 = matrix[2];
|
|
151
|
+
mat3 result = mat3(
|
|
152
|
+
vec3(row0.x, row1.x, row2.x),
|
|
153
|
+
vec3(row0.y, row1.y, row2.y),
|
|
154
|
+
vec3(row0.z, row1.z, row2.z)
|
|
155
|
+
);
|
|
156
|
+
return result;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
float det(mat2 matrix) {
|
|
160
|
+
return matrix[0].x * matrix[1].y - matrix[0].y * matrix[1].x;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
mat3 inverse(mat3 matrix) {
|
|
164
|
+
vec3 row0 = matrix[0];
|
|
165
|
+
vec3 row1 = matrix[1];
|
|
166
|
+
vec3 row2 = matrix[2];
|
|
167
|
+
|
|
168
|
+
vec3 minors0 = vec3(
|
|
169
|
+
det(mat2(row1.y, row1.z, row2.y, row2.z)),
|
|
170
|
+
det(mat2(row1.z, row1.x, row2.z, row2.x)),
|
|
171
|
+
det(mat2(row1.x, row1.y, row2.x, row2.y))
|
|
172
|
+
);
|
|
173
|
+
vec3 minors1 = vec3(
|
|
174
|
+
det(mat2(row2.y, row2.z, row0.y, row0.z)),
|
|
175
|
+
det(mat2(row2.z, row2.x, row0.z, row0.x)),
|
|
176
|
+
det(mat2(row2.x, row2.y, row0.x, row0.y))
|
|
177
|
+
);
|
|
178
|
+
vec3 minors2 = vec3(
|
|
179
|
+
det(mat2(row0.y, row0.z, row1.y, row1.z)),
|
|
180
|
+
det(mat2(row0.z, row0.x, row1.z, row1.x)),
|
|
181
|
+
det(mat2(row0.x, row0.y, row1.x, row1.y))
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
mat3 adj = transpose(mat3(minors0, minors1, minors2));
|
|
185
|
+
|
|
186
|
+
return (1.0 / dot(row0, minors0)) * adj;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
void main(void) {
|
|
190
|
+
|
|
191
|
+
vec3 dir = computeView(tc);
|
|
192
|
+
dir = inverse(mat3(viewMatrix)) * dir;
|
|
193
|
+
|
|
194
|
+
vec2 ER = sphIntersect(camPos, dir, vec3(0.0), earthRadius);
|
|
195
|
+
|
|
196
|
+
float bigRadius = earthRadius * 2.5;
|
|
197
|
+
vec3 bigCenter = normalize(camPos) * bigRadius * 1.3;
|
|
198
|
+
|
|
199
|
+
vec2 BIG = sphIntersect(camPos, dir, bigCenter, bigRadius);
|
|
200
|
+
|
|
201
|
+
float Ix = distance(camPos + dir * BIG.y, ZERO);
|
|
202
|
+
|
|
203
|
+
float maxI = sqrt(bigRadius * bigRadius + bigRadius * bigRadius);
|
|
204
|
+
|
|
205
|
+
gl_FragColor = vec4(mix(colorOne, colorTwo, Ix / maxI), 1.0);
|
|
206
|
+
}`
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export { SimpleSkyBackground };
|
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
|
|
package/src/og/control/index.js
CHANGED
|
@@ -11,12 +11,15 @@ import { ToggleWireframe } from "./ToggleWireframe.js";
|
|
|
11
11
|
import { TouchNavigation } from "./TouchNavigation.js";
|
|
12
12
|
import { SimpleNavigation } from "./SimpleNavigation.js";
|
|
13
13
|
import { Ruler } from "./ruler/Ruler.js";
|
|
14
|
+
import { Selection } from "./selection/Selection.js";
|
|
14
15
|
import { ShowFps } from "./ShowFps.js";
|
|
15
16
|
import { Sun } from "./Sun.js";
|
|
16
17
|
import { ZoomControl } from "./ZoomControl.js";
|
|
17
18
|
import { MouseWheelZoomControl } from "./MouseWheelZoomControl.js";
|
|
18
19
|
import { Lighting } from "./Lighting.js";
|
|
19
20
|
import { LayerAnimation } from "./LayerAnimation.js";
|
|
21
|
+
import { ScaleControl } from "./ScaleControl.js";
|
|
22
|
+
import { SimpleSkyBackground } from "./SimpleSkyBackground.js";
|
|
20
23
|
|
|
21
24
|
export {
|
|
22
25
|
Control,
|
|
@@ -32,10 +35,13 @@ export {
|
|
|
32
35
|
TouchNavigation,
|
|
33
36
|
SimpleNavigation,
|
|
34
37
|
ShowFps,
|
|
38
|
+
ScaleControl,
|
|
35
39
|
Sun,
|
|
36
40
|
ZoomControl,
|
|
37
41
|
MouseWheelZoomControl,
|
|
38
42
|
Lighting,
|
|
39
43
|
Ruler,
|
|
44
|
+
SimpleSkyBackground,
|
|
45
|
+
Selection,
|
|
40
46
|
LayerAnimation
|
|
41
47
|
};
|
|
@@ -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++) {
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module og/control/Selector
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
import { Control } from "../Control.js";
|
|
8
|
+
import { SelectionScene } from "./SelectionScene.js";
|
|
9
|
+
import { ToggleButton } from "../../ui/ToggleButton.js";
|
|
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>`;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Activate Selection
|
|
16
|
+
* @class
|
|
17
|
+
* @extends {Control}
|
|
18
|
+
* @param {Object} [options] - Control options.
|
|
19
|
+
* @param {boolean} [options.ignoreTerrain=false].
|
|
20
|
+
* @param {function} options.onSelect - callback (extent) => {} where extent is selected extent array [minLon,minLat,maxLon,maxLat]
|
|
21
|
+
* @param {boolean} [options.autoSelectionHide=false] - clear selection rectangle after passing extent to callback
|
|
22
|
+
* @example:
|
|
23
|
+
* to use bootstrap icons, include
|
|
24
|
+
* <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.2/font/bootstrap-icons.css">
|
|
25
|
+
*
|
|
26
|
+
* new Selection({
|
|
27
|
+
* ignoreTerrain: false,
|
|
28
|
+
* autoSelectionHide:true,
|
|
29
|
+
* onSelect: (extent) => {
|
|
30
|
+
*
|
|
31
|
+
* var vectorSource = new ol.source.Vector({
|
|
32
|
+
* format: new GeoJSON(),
|
|
33
|
+
* url: function (extent) {
|
|
34
|
+
* return 'https://snap.ogs.trieste.it/geoserver/snap/ows?service=WFS&' +
|
|
35
|
+
* 'version=1.1.0&request=GetFeature&typename=snap:all_dataset_segy_view&' +
|
|
36
|
+
* 'outputFormat=application/json&srsname=EPSG:4326&' +
|
|
37
|
+
* 'bbox=' + extent.join(',') + ',EPSG:4326';
|
|
38
|
+
* },
|
|
39
|
+
* strategy: function (extent, resolution) {
|
|
40
|
+
* if (this.resolution && this.resolution != resolution) {
|
|
41
|
+
* this.loadedExtentsRtree_.clear();
|
|
42
|
+
* }
|
|
43
|
+
* return [extent];
|
|
44
|
+
* }
|
|
45
|
+
* });
|
|
46
|
+
*
|
|
47
|
+
* vectorSource.loadFeatures(extent);
|
|
48
|
+
*
|
|
49
|
+
* console.log(extent);
|
|
50
|
+
*
|
|
51
|
+
* }
|
|
52
|
+
* });
|
|
53
|
+
*/
|
|
54
|
+
class Selection extends Control {
|
|
55
|
+
constructor(options = {}) {
|
|
56
|
+
super(options);
|
|
57
|
+
|
|
58
|
+
this._selectorScene = new SelectionScene({
|
|
59
|
+
name: `selectionScene:${this._id}`,
|
|
60
|
+
ignoreTerrain: options.ignoreTerrain,
|
|
61
|
+
onSelect: options.onSelect,
|
|
62
|
+
autoSelectionHide: options.autoSelectionHide
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
this._toggleBtn = new ToggleButton({
|
|
67
|
+
classList: ["og-map-button", "og-selection_button"],
|
|
68
|
+
icon: ICON_BUTTON_SVG
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
set ignoreTerrain(v) {
|
|
73
|
+
this._selectorScene.ignoreTerrain = v;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
oninit() {
|
|
77
|
+
this._toggleBtn.appendTo(this.renderer.div);
|
|
78
|
+
|
|
79
|
+
this._toggleBtn.on("change", (isActive) => {
|
|
80
|
+
if (isActive) {
|
|
81
|
+
this.activate();
|
|
82
|
+
} else {
|
|
83
|
+
this.deactivate();
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
this._selectorScene.bindPlanet(this.planet);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
onactivate() {
|
|
91
|
+
this.renderer.addNode(this._selectorScene);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
ondeactivate() {
|
|
95
|
+
this.renderer.removeNode(this._selectorScene);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export { Selection };
|