@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
|
@@ -1,188 +1,187 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module og/control/Control
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
"use strict";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Base control class for implementing renderer controls.
|
|
9
|
-
* All other controls extend from this class.
|
|
10
|
-
* @class
|
|
11
|
-
* @param {Object} [options] - Control activation options:
|
|
12
|
-
* @param {Boolean} [options.autoActivated=true] - If true - calls initialize function after the renderer assigning.
|
|
13
|
-
*/
|
|
14
|
-
class Control {
|
|
15
|
-
/**
|
|
16
|
-
* @param {Object} [options] - Control activation options:
|
|
17
|
-
*/
|
|
18
|
-
constructor(options) {
|
|
19
|
-
options = options || {};
|
|
20
|
-
|
|
21
|
-
this._id = Control.__staticCounter++;
|
|
22
|
-
|
|
23
|
-
this._name = options.name || "_control_" + this._id;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Control initialized.
|
|
27
|
-
* @protected
|
|
28
|
-
* @type {Boolean}
|
|
29
|
-
*/
|
|
30
|
-
this._initialized = false;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Assigned renderer.
|
|
34
|
-
* @public
|
|
35
|
-
* @type {Renderer}
|
|
36
|
-
*/
|
|
37
|
-
this.renderer = null;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Auto activation flag.
|
|
41
|
-
* @public
|
|
42
|
-
* @type {Boolean}
|
|
43
|
-
*/
|
|
44
|
-
this.autoActivate = options.autoActivate != undefined ? options.autoActivate : true;
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Control activity.
|
|
48
|
-
* @protected
|
|
49
|
-
* @type {Boolean}
|
|
50
|
-
*/
|
|
51
|
-
this._active = false;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
static get __staticCounter() {
|
|
55
|
-
if (!this.__counter && this.__counter !== 0) {
|
|
56
|
-
this.__counter = 0;
|
|
57
|
-
}
|
|
58
|
-
return this.__counter;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
static set __staticCounter(n) {
|
|
62
|
-
this.__counter = n;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Returns control name.
|
|
67
|
-
* @public
|
|
68
|
-
* @virtual
|
|
69
|
-
*/
|
|
70
|
-
get name() {
|
|
71
|
-
return this._name;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Control initialization function have to be overriden.
|
|
76
|
-
* @public
|
|
77
|
-
* @virtual
|
|
78
|
-
*/
|
|
79
|
-
oninit() {}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Control renderer assigning function have to be overriden.
|
|
83
|
-
* @public
|
|
84
|
-
* @virtual
|
|
85
|
-
*/
|
|
86
|
-
onadd() {}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Control remove function have to be overriden.
|
|
90
|
-
* @public
|
|
91
|
-
* @virtual
|
|
92
|
-
*/
|
|
93
|
-
onremove() {}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Control activation function have to be overriden.
|
|
97
|
-
* @public
|
|
98
|
-
* @virtual
|
|
99
|
-
*/
|
|
100
|
-
onactivate() {}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Control deactivation function have to be overriden.
|
|
104
|
-
* @public
|
|
105
|
-
* @virtual
|
|
106
|
-
*/
|
|
107
|
-
ondeactivate() {}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Assign renderer to the control.
|
|
111
|
-
* @public
|
|
112
|
-
* @type {Renderer}
|
|
113
|
-
*/
|
|
114
|
-
addTo(renderer) {
|
|
115
|
-
if (renderer) {
|
|
116
|
-
this.renderer = renderer;
|
|
117
|
-
renderer.controls[this.name] = this;
|
|
118
|
-
this.onadd && this.onadd();
|
|
119
|
-
if (this.autoActivate) {
|
|
120
|
-
this._initialized = true;
|
|
121
|
-
this.oninit && this.oninit();
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
*
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
r.controls[n]
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
this.
|
|
149
|
-
this.
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
*
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
this.
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
this.
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
*
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
this.
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
*
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
export { Control };
|
|
1
|
+
/**
|
|
2
|
+
* @module og/control/Control
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Base control class for implementing renderer controls.
|
|
9
|
+
* All other controls extend from this class.
|
|
10
|
+
* @class
|
|
11
|
+
* @param {Object} [options] - Control activation options:
|
|
12
|
+
* @param {Boolean} [options.autoActivated=true] - If true - calls initialize function after the renderer assigning.
|
|
13
|
+
*/
|
|
14
|
+
class Control {
|
|
15
|
+
/**
|
|
16
|
+
* @param {Object} [options] - Control activation options:
|
|
17
|
+
*/
|
|
18
|
+
constructor(options) {
|
|
19
|
+
options = options || {};
|
|
20
|
+
|
|
21
|
+
this._id = Control.__staticCounter++;
|
|
22
|
+
|
|
23
|
+
this._name = options.name || "_control_" + this._id;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Control initialized.
|
|
27
|
+
* @protected
|
|
28
|
+
* @type {Boolean}
|
|
29
|
+
*/
|
|
30
|
+
this._initialized = false;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Assigned renderer.
|
|
34
|
+
* @public
|
|
35
|
+
* @type {Renderer}
|
|
36
|
+
*/
|
|
37
|
+
this.renderer = null;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Auto activation flag.
|
|
41
|
+
* @public
|
|
42
|
+
* @type {Boolean}
|
|
43
|
+
*/
|
|
44
|
+
this.autoActivate = options.autoActivate != undefined ? options.autoActivate : true;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Control activity.
|
|
48
|
+
* @protected
|
|
49
|
+
* @type {Boolean}
|
|
50
|
+
*/
|
|
51
|
+
this._active = false;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
static get __staticCounter() {
|
|
55
|
+
if (!this.__counter && this.__counter !== 0) {
|
|
56
|
+
this.__counter = 0;
|
|
57
|
+
}
|
|
58
|
+
return this.__counter;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
static set __staticCounter(n) {
|
|
62
|
+
this.__counter = n;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Returns control name.
|
|
67
|
+
* @public
|
|
68
|
+
* @virtual
|
|
69
|
+
*/
|
|
70
|
+
get name() {
|
|
71
|
+
return this._name;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Control initialization function have to be overriden.
|
|
76
|
+
* @public
|
|
77
|
+
* @virtual
|
|
78
|
+
*/
|
|
79
|
+
oninit() {}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Control renderer assigning function have to be overriden.
|
|
83
|
+
* @public
|
|
84
|
+
* @virtual
|
|
85
|
+
*/
|
|
86
|
+
onadd() {}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Control remove function have to be overriden.
|
|
90
|
+
* @public
|
|
91
|
+
* @virtual
|
|
92
|
+
*/
|
|
93
|
+
onremove() {}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Control activation function have to be overriden.
|
|
97
|
+
* @public
|
|
98
|
+
* @virtual
|
|
99
|
+
*/
|
|
100
|
+
onactivate() {}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Control deactivation function have to be overriden.
|
|
104
|
+
* @public
|
|
105
|
+
* @virtual
|
|
106
|
+
*/
|
|
107
|
+
ondeactivate() {}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Assign renderer to the control.
|
|
111
|
+
* @public
|
|
112
|
+
* @type {Renderer}
|
|
113
|
+
*/
|
|
114
|
+
addTo(renderer) {
|
|
115
|
+
if (renderer) {
|
|
116
|
+
this.renderer = renderer;
|
|
117
|
+
renderer.controls[this.name] = this;
|
|
118
|
+
this.onadd && this.onadd();
|
|
119
|
+
if (this.autoActivate) {
|
|
120
|
+
this._initialized = true;
|
|
121
|
+
this.oninit && this.oninit();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Assign renderer to the control.
|
|
128
|
+
* @public
|
|
129
|
+
*/
|
|
130
|
+
remove() {
|
|
131
|
+
this.onremove && this.onremove();
|
|
132
|
+
|
|
133
|
+
let r = this.renderer,
|
|
134
|
+
n = this.name;
|
|
135
|
+
|
|
136
|
+
if (!r) return;
|
|
137
|
+
|
|
138
|
+
let c = r.controls[n];
|
|
139
|
+
|
|
140
|
+
if (c) {
|
|
141
|
+
if (this.isEqual(c)) {
|
|
142
|
+
r.controls[n] = null;
|
|
143
|
+
delete r.controls[n];
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
this.renderer = null;
|
|
148
|
+
this._active = false;
|
|
149
|
+
this._initialized = false;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Activate control.
|
|
154
|
+
* @public
|
|
155
|
+
*/
|
|
156
|
+
activate() {
|
|
157
|
+
if (!this._initialized) {
|
|
158
|
+
this._initialized = true;
|
|
159
|
+
this.oninit && this.oninit();
|
|
160
|
+
}
|
|
161
|
+
this._active = true;
|
|
162
|
+
this.onactivate && this.onactivate();
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Deactivate control.
|
|
167
|
+
* @public
|
|
168
|
+
*/
|
|
169
|
+
deactivate() {
|
|
170
|
+
this._active = false;
|
|
171
|
+
this.ondeactivate && this.ondeactivate();
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Is control active.
|
|
176
|
+
* @public
|
|
177
|
+
*/
|
|
178
|
+
isActive() {
|
|
179
|
+
return this._active;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
isEqual(control) {
|
|
183
|
+
return control._id === this._id;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export { Control };
|
|
@@ -6,96 +6,114 @@
|
|
|
6
6
|
|
|
7
7
|
import { Control } from './Control.js';
|
|
8
8
|
import { BaseGeoImage } from '../layer/BaseGeoImage.js';
|
|
9
|
-
import {
|
|
9
|
+
import { ToggleButton } from "../ui/ToggleButton.js";
|
|
10
|
+
|
|
11
|
+
const ICON_BUTTON_SVG = `<?xml version="1.0" encoding="UTF-8" standalone="no"?> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path d="M16 13l6.964 4.062-2.973.85 2.125 3.681-1.732 1-2.125-3.68-2.223 2.15L16 13zm-2-7h2v2h5a1 1 0 0 1 1 1v4h-2v-3H10v10h4v2H9a1 1 0 0 1-1-1v-5H6v-2h2V9a1 1 0 0 1 1-1h5V6zM4 14v2H2v-2h2zm0-4v2H2v-2h2zm0-4v2H2V6h2zm0-4v2H2V2h2zm4 0v2H6V2h2zm4 0v2h-2V2h2zm4 0v2h-2V2h2z" fill="#000"/></svg>`;
|
|
10
12
|
|
|
11
13
|
class GeoImageDragControl extends Control {
|
|
12
14
|
constructor(options = {}) {
|
|
13
15
|
super(options);
|
|
16
|
+
|
|
14
17
|
this._cornerIndex = -1;
|
|
15
18
|
this._catchCorner = false;
|
|
19
|
+
|
|
20
|
+
this._toggleBtn = new ToggleButton({
|
|
21
|
+
classList: ["og-map-button", "og-geoimagegrag_button"],
|
|
22
|
+
icon: ICON_BUTTON_SVG
|
|
23
|
+
});
|
|
24
|
+
|
|
16
25
|
}
|
|
17
26
|
|
|
18
27
|
oninit() {
|
|
19
|
-
|
|
20
|
-
this.createDraggerButton();
|
|
28
|
+
this._toggleBtn.appendTo(this.renderer.div);
|
|
21
29
|
|
|
22
|
-
|
|
23
|
-
this.
|
|
30
|
+
this.planet.events.on('layeradd', function (e) {
|
|
31
|
+
if (this.isActive()) {
|
|
32
|
+
this._bindLayer(e);
|
|
33
|
+
}
|
|
24
34
|
}, this);
|
|
25
35
|
|
|
26
|
-
|
|
27
|
-
if (
|
|
28
|
-
this.
|
|
36
|
+
this._toggleBtn.on("change", (isActive) => {
|
|
37
|
+
if (isActive) {
|
|
38
|
+
this.activate();
|
|
39
|
+
} else {
|
|
40
|
+
this.deactivate();
|
|
29
41
|
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
onactivate() {
|
|
46
|
+
super.onactivate();
|
|
47
|
+
|
|
48
|
+
let p = this.planet;
|
|
49
|
+
for (let i = 0; i < p.layers.length; i++) {
|
|
50
|
+
this._bindLayer(p.layers[i]);
|
|
30
51
|
}
|
|
31
|
-
btnClickHandler('og-geo-image-dragger-menu-btn', null, null, '#og-geo-image-dragger-menu-icon'); // btn_id, dialog_id, dialog_selector, icon_id
|
|
32
52
|
}
|
|
33
53
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
let
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
elementFactory('div', { id: 'og-geo-image-dragger-menu-icon', class: 'og-icon-holder' }));
|
|
41
|
-
this.renderer.div.appendChild(btn);
|
|
54
|
+
ondeactivate() {
|
|
55
|
+
super.ondeactivate();
|
|
56
|
+
let p = this.planet;
|
|
57
|
+
for (let i = 0; i < p.layers.length; i++) {
|
|
58
|
+
this._unbindLayer(p.layers[i]);
|
|
59
|
+
}
|
|
42
60
|
}
|
|
43
61
|
|
|
44
62
|
_bindLayer(layer) {
|
|
45
|
-
if (layer instanceof BaseGeoImage) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
layer.events.on('
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (this._active && !btn_off) { // active layer and button ON
|
|
53
|
-
if (this._catchCorner) {// mouse is catching a corner
|
|
54
|
-
var corners = layer.getCornersLonLat();
|
|
55
|
-
corners[this._cornerIndex] = p.getLonLatFromPixelTerrain(ms, true);
|
|
56
|
-
layer.setCornersLonLat(corners);
|
|
57
|
-
} else { // mouse isn't catching
|
|
58
|
-
this._cornerIndex = -1;
|
|
59
|
-
for (var i = 0; i < layer._cornersWgs84.length; i++) {
|
|
60
|
-
var ground = p.getLonLatFromPixelTerrain(ms, true);
|
|
61
|
-
// mouse is near
|
|
62
|
-
if (ground && p.ellipsoid.getGreatCircleDistance(layer._cornersWgs84[i], ground) / p.getDistanceFromPixel(ms, true) <= 0.05) {
|
|
63
|
-
this._cornerIndex = i;
|
|
64
|
-
document.body.style.cursor = 'move';
|
|
65
|
-
break;
|
|
66
|
-
// mouse is far
|
|
67
|
-
} else {
|
|
68
|
-
document.body.style.cursor = 'auto';
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
layer.events.on("mouseleave", function () {
|
|
76
|
-
document.body.style.cursor = 'auto';
|
|
77
|
-
});
|
|
63
|
+
if (layer instanceof BaseGeoImage) {
|
|
64
|
+
layer.events.on('mousemove', this._onMouseMove, this);
|
|
65
|
+
layer.events.on("mouseleave", this._onMouseLeave, this);
|
|
66
|
+
layer.events.on('ldown', this._onLDown, this);
|
|
67
|
+
layer.events.on('lup', this._onLUp, this);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
78
70
|
|
|
79
|
-
|
|
71
|
+
_unbindLayer(layer) {
|
|
72
|
+
if (layer instanceof BaseGeoImage) {
|
|
73
|
+
layer.events.off('mousemove', this._onMouseMove);
|
|
74
|
+
layer.events.off("mouseleave", this._onMouseLeave);
|
|
75
|
+
layer.events.off('ldown', this._onLDown);
|
|
76
|
+
layer.events.off('lup', this._onLUp);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
80
79
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
}, this);
|
|
80
|
+
_onLUp(ms) {
|
|
81
|
+
this._catchCorner = false;
|
|
82
|
+
ms.renderer.controls.mouseNavigation.activate();
|
|
83
|
+
}
|
|
87
84
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
85
|
+
_onLDown(ms) {
|
|
86
|
+
if (this._cornerIndex !== -1) {
|
|
87
|
+
this._catchCorner = true;
|
|
88
|
+
ms.renderer.controls.mouseNavigation.deactivate();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
94
91
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
92
|
+
_onMouseLeave() {
|
|
93
|
+
document.body.style.cursor = 'auto';
|
|
94
|
+
}
|
|
98
95
|
|
|
96
|
+
_onMouseMove(ms) {
|
|
97
|
+
let layer = ms.pickingObject,
|
|
98
|
+
p = this.planet;
|
|
99
|
+
if (this._catchCorner) {// mouse is catching a corner
|
|
100
|
+
let corners = layer.getCornersLonLat();
|
|
101
|
+
corners[this._cornerIndex] = p.getLonLatFromPixelTerrain(ms, true);
|
|
102
|
+
layer.setCornersLonLat(corners);
|
|
103
|
+
} else { // mouse isn't catching
|
|
104
|
+
this._cornerIndex = -1;
|
|
105
|
+
for (let i = 0; i < layer._cornersWgs84.length; i++) {
|
|
106
|
+
let ground = p.getLonLatFromPixelTerrain(ms, true);
|
|
107
|
+
// mouse is near
|
|
108
|
+
if (ground && p.ellipsoid.getGreatCircleDistance(layer._cornersWgs84[i], ground) / p.getDistanceFromPixel(ms, true) <= 0.05) {
|
|
109
|
+
this._cornerIndex = i;
|
|
110
|
+
document.body.style.cursor = 'move';
|
|
111
|
+
break;
|
|
112
|
+
// mouse is far
|
|
113
|
+
} else {
|
|
114
|
+
document.body.style.cursor = 'auto';
|
|
115
|
+
}
|
|
116
|
+
}
|
|
99
117
|
}
|
|
100
118
|
}
|
|
101
119
|
}
|