@openglobus/og 0.13.5 → 0.13.8
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 +66 -25
- 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 +1 -1
- package/src/og/Events.js +188 -188
- package/src/og/Extent.js +1 -9
- package/src/og/Globe.js +1 -0
- package/src/og/Object3d.js +384 -0
- package/src/og/arial.js +1705 -1703
- package/src/og/camera/Camera.js +640 -640
- package/src/og/control/DebugInfo.js +15 -4
- package/src/og/control/EarthCoordinates.js +151 -160
- package/src/og/control/KeyboardNavigation.js +48 -2
- package/src/og/control/LayerAnimation.js +115 -0
- package/src/og/control/MouseNavigation.js +460 -460
- package/src/og/control/Sun.js +170 -170
- package/src/og/control/TouchNavigation.js +13 -13
- package/src/og/control/ZoomControl.js +1 -3
- package/src/og/control/index.js +3 -1
- package/src/og/control/ruler/Ruler.js +43 -0
- package/src/og/control/ruler/RulerScene.js +370 -0
- package/src/og/control/visibleExtent/Segment.js +1 -4
- package/src/og/ellipsoid/Ellipsoid.js +20 -1
- package/src/og/entity/Entity.js +1 -1
- package/src/og/entity/GeoObject.js +1 -1
- package/src/og/entity/LabelHandler.js +3 -2
- package/src/og/input/input.js +7 -1
- package/src/og/layer/CanvasTiles.js +8 -8
- package/src/og/layer/KML.js +181 -12
- package/src/og/layer/Layer.js +27 -42
- package/src/og/layer/Vector.js +80 -14
- package/src/og/layer/XYZ.js +8 -2
- package/src/og/math/Vec3.js +1 -1
- package/src/og/math.js +4 -4
- package/src/og/quadTree/Node.js +2 -1
- package/src/og/renderer/Renderer.js +1 -2
- package/src/og/renderer/RendererEvents.js +17 -3
- package/src/og/res/images.js +0 -2
- package/src/og/scene/Planet.js +92 -32
- package/src/og/segment/Segment.js +1 -8
- package/src/og/shaders/label.js +30 -42
- package/src/og/terrain/EmptyTerrain.js +164 -146
- package/src/og/terrain/Geoid.js +246 -241
- package/src/og/terrain/GlobusTerrain.js +23 -24
- package/src/og/terrain/MapboxTerrain.js +292 -294
- package/src/og/utils/FontAtlas.js +1 -2
- package/src/og/utils/Loader.js +160 -112
- package/src/og/utils/PlainSegmentWorker.js +38 -26
- package/src/og/utils/VectorTileCreator.js +1 -1
- package/src/og/utils/units.js +78 -0
- package/src/og/webgl/ProgramController.js +143 -143
- package/types/Object3d.d.ts +21 -0
- package/types/arial.d.ts +1 -0
- package/types/control/EarthCoordinates.d.ts +27 -30
- package/types/control/KeyboardNavigation.d.ts +3 -0
- package/types/control/Sun.d.ts +1 -1
- package/types/control/index.d.ts +2 -1
- package/types/control/ruler/Ruler.d.ts +13 -0
- package/types/control/ruler/RulerScene.d.ts +48 -0
- package/types/ellipsoid/Ellipsoid.d.ts +8 -0
- package/types/input/input.d.ts +6 -0
- package/types/layer/KML.d.ts +26 -1
- package/types/layer/Layer.d.ts +23 -31
- package/types/layer/Vector.d.ts +2 -0
- package/types/layer/XYZ.d.ts +1 -0
- package/types/math.d.ts +1 -1
- package/types/renderer/RendererEvents.d.ts +2 -0
- package/types/res/images.d.ts +0 -1
- package/types/scene/Planet.d.ts +12 -3
- package/types/terrain/EmptyTerrain.d.ts +4 -1
- package/types/terrain/Geoid.d.ts +1 -10
- package/types/terrain/GlobusTerrain.d.ts +0 -2
- package/types/terrain/MapboxTerrain.d.ts +1 -1
- package/types/utils/Loader.d.ts +4 -0
- package/types/utils/units.d.ts +20 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openglobus/og",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.8",
|
|
4
4
|
"description": "[OpenGlobus](http://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"
|
package/src/og/Events.js
CHANGED
|
@@ -1,188 +1,188 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module og/Events
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
"use strict";
|
|
6
|
-
|
|
7
|
-
import { stamp, binaryInsert } from "./utils/shared.js";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Base events class to handle custom events.
|
|
11
|
-
* @class
|
|
12
|
-
*/
|
|
13
|
-
class Events {
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
16
|
-
* @param {Array.<string>} [eventNames] - Event names that could be dispatched.
|
|
17
|
-
* @param {*} [sender]
|
|
18
|
-
*/
|
|
19
|
-
constructor(eventNames, sender) {
|
|
20
|
-
/**
|
|
21
|
-
* Registered event names.
|
|
22
|
-
* @protected
|
|
23
|
-
* @type {Array.<string>}
|
|
24
|
-
*/
|
|
25
|
-
this._eventNames = [];
|
|
26
|
-
|
|
27
|
-
eventNames && this.registerNames(eventNames);
|
|
28
|
-
|
|
29
|
-
this._sender = sender || this;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Stop propagation flag
|
|
33
|
-
* @protected
|
|
34
|
-
* @type {boolean}
|
|
35
|
-
*/
|
|
36
|
-
this._stopPropagation = false;
|
|
37
|
-
|
|
38
|
-
this._stampCache = {};
|
|
39
|
-
|
|
40
|
-
this.__id = Events._staticCounter++;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
static get _staticCounter() {
|
|
44
|
-
if (!this.__counter__ && this.__counter__ !== 0) {
|
|
45
|
-
this.__counter__ = 0;
|
|
46
|
-
}
|
|
47
|
-
return this.__counter__;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
static set _staticCounter(n) {
|
|
51
|
-
this.__counter__ = n;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
bindSender(sender) {
|
|
55
|
-
this._sender = sender || this;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Function that creates event object properties that would be dispatched.
|
|
60
|
-
* @public
|
|
61
|
-
* @param {Array.<string>} eventNames - Specified event names list.
|
|
62
|
-
*/
|
|
63
|
-
registerNames(eventNames) {
|
|
64
|
-
for (var i = 0; i < eventNames.length; i++) {
|
|
65
|
-
this[eventNames[i]] = { active: true, handlers: [] };
|
|
66
|
-
this._eventNames.push(eventNames[i]);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
_getStamp(name, id, ogid) {
|
|
71
|
-
return `${name}_${id}_${ogid}`;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Returns true if event callback has stamped.
|
|
76
|
-
* @protected
|
|
77
|
-
* @param {Object} name - Event identifier.
|
|
78
|
-
* @param {Object} obj - Event callback.
|
|
79
|
-
* @return {boolean} -
|
|
80
|
-
*/
|
|
81
|
-
_stamp(name, obj) {
|
|
82
|
-
var ogid = stamp(obj);
|
|
83
|
-
|
|
84
|
-
var st = this._getStamp(name, this.__id, ogid);
|
|
85
|
-
|
|
86
|
-
if (!this._stampCache[st]) {
|
|
87
|
-
this._stampCache[st] = ogid;
|
|
88
|
-
return true;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return false;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Attach listener.
|
|
96
|
-
* @public
|
|
97
|
-
* @param {string} name - Event name to listen.
|
|
98
|
-
* @param {eventCallback} callback - Event callback function.
|
|
99
|
-
* @param {Object} sender - Event callback function owner.
|
|
100
|
-
*/
|
|
101
|
-
on(name, callback, sender, priority = 0) {
|
|
102
|
-
if (this._stamp(name, callback)) {
|
|
103
|
-
if (this[name]) {
|
|
104
|
-
let c = callback.bind(sender || this._sender);
|
|
105
|
-
c._openglobus_id = callback._openglobus_id;
|
|
106
|
-
c._openglobus_priority = priority;
|
|
107
|
-
binaryInsert(this[name].handlers, c, (a, b) => {
|
|
108
|
-
return b._openglobus_priority - a._openglobus_priority;
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Stop listening event name with specified callback function.
|
|
116
|
-
* @public
|
|
117
|
-
* @param {string} name - Event name.
|
|
118
|
-
* @param {eventCallback} callback - Attached event callback.
|
|
119
|
-
*/
|
|
120
|
-
off(name, callback) {
|
|
121
|
-
if (callback) {
|
|
122
|
-
var st = this._getStamp(name, this.__id, callback._openglobus_id);
|
|
123
|
-
if (callback._openglobus_id && this._stampCache[st]) {
|
|
124
|
-
var h = this[name].handlers;
|
|
125
|
-
var i = h.length;
|
|
126
|
-
var indexToRemove = -1;
|
|
127
|
-
while (i--) {
|
|
128
|
-
var hi = h[i];
|
|
129
|
-
if (hi._openglobus_id === callback._openglobus_id) {
|
|
130
|
-
indexToRemove = i;
|
|
131
|
-
break;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if (indexToRemove !== -1) {
|
|
136
|
-
h.splice(indexToRemove, 1);
|
|
137
|
-
this._stampCache[st] = undefined;
|
|
138
|
-
delete this._stampCache[st];
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Dispatch event.
|
|
146
|
-
* @public
|
|
147
|
-
* @param {Object} event - Event instance property that created by event name.
|
|
148
|
-
* @param {Object} [obj] - Event object.
|
|
149
|
-
*/
|
|
150
|
-
dispatch(event, ...args) {
|
|
151
|
-
let result = true;
|
|
152
|
-
if (event && event.active && !this._stopPropagation) {
|
|
153
|
-
let h = event.handlers,
|
|
154
|
-
i = h.length;
|
|
155
|
-
while (i--) {
|
|
156
|
-
if (h[i](...args) === false) {
|
|
157
|
-
result = false;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
this._stopPropagation = false;
|
|
162
|
-
return result;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Brakes events propagation.
|
|
167
|
-
* @public
|
|
168
|
-
*/
|
|
169
|
-
stopPropagation() {
|
|
170
|
-
this._stopPropagation = true;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* Removes all events.
|
|
175
|
-
* @public
|
|
176
|
-
*/
|
|
177
|
-
clear() {
|
|
178
|
-
for (var i = 0; i < this._eventNames.length; i++) {
|
|
179
|
-
var e = this[this._eventNames[i]];
|
|
180
|
-
e.handlers.length = 0;
|
|
181
|
-
e.handlers = [];
|
|
182
|
-
}
|
|
183
|
-
this._eventNames.length = 0;
|
|
184
|
-
this._eventNames = [];
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
export { Events };
|
|
1
|
+
/**
|
|
2
|
+
* @module og/Events
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
import { stamp, binaryInsert } from "./utils/shared.js";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Base events class to handle custom events.
|
|
11
|
+
* @class
|
|
12
|
+
*/
|
|
13
|
+
class Events {
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @param {Array.<string>} [eventNames] - Event names that could be dispatched.
|
|
17
|
+
* @param {*} [sender]
|
|
18
|
+
*/
|
|
19
|
+
constructor(eventNames, sender) {
|
|
20
|
+
/**
|
|
21
|
+
* Registered event names.
|
|
22
|
+
* @protected
|
|
23
|
+
* @type {Array.<string>}
|
|
24
|
+
*/
|
|
25
|
+
this._eventNames = [];
|
|
26
|
+
|
|
27
|
+
eventNames && this.registerNames(eventNames);
|
|
28
|
+
|
|
29
|
+
this._sender = sender || this;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Stop propagation flag
|
|
33
|
+
* @protected
|
|
34
|
+
* @type {boolean}
|
|
35
|
+
*/
|
|
36
|
+
this._stopPropagation = false;
|
|
37
|
+
|
|
38
|
+
this._stampCache = {};
|
|
39
|
+
|
|
40
|
+
this.__id = Events._staticCounter++;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
static get _staticCounter() {
|
|
44
|
+
if (!this.__counter__ && this.__counter__ !== 0) {
|
|
45
|
+
this.__counter__ = 0;
|
|
46
|
+
}
|
|
47
|
+
return this.__counter__;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
static set _staticCounter(n) {
|
|
51
|
+
this.__counter__ = n;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
bindSender(sender) {
|
|
55
|
+
this._sender = sender || this;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Function that creates event object properties that would be dispatched.
|
|
60
|
+
* @public
|
|
61
|
+
* @param {Array.<string>} eventNames - Specified event names list.
|
|
62
|
+
*/
|
|
63
|
+
registerNames(eventNames) {
|
|
64
|
+
for (var i = 0; i < eventNames.length; i++) {
|
|
65
|
+
this[eventNames[i]] = { active: true, handlers: [] };
|
|
66
|
+
this._eventNames.push(eventNames[i]);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
_getStamp(name, id, ogid) {
|
|
71
|
+
return `${name}_${id}_${ogid}`;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Returns true if event callback has stamped.
|
|
76
|
+
* @protected
|
|
77
|
+
* @param {Object} name - Event identifier.
|
|
78
|
+
* @param {Object} obj - Event callback.
|
|
79
|
+
* @return {boolean} -
|
|
80
|
+
*/
|
|
81
|
+
_stamp(name, obj) {
|
|
82
|
+
var ogid = stamp(obj);
|
|
83
|
+
|
|
84
|
+
var st = this._getStamp(name, this.__id, ogid);
|
|
85
|
+
|
|
86
|
+
if (!this._stampCache[st]) {
|
|
87
|
+
this._stampCache[st] = ogid;
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Attach listener.
|
|
96
|
+
* @public
|
|
97
|
+
* @param {string} name - Event name to listen.
|
|
98
|
+
* @param {eventCallback} callback - Event callback function.
|
|
99
|
+
* @param {Object} sender - Event callback function owner.
|
|
100
|
+
*/
|
|
101
|
+
on(name, callback, sender, priority = 0) {
|
|
102
|
+
if (this._stamp(name, callback)) {
|
|
103
|
+
if (this[name]) {
|
|
104
|
+
let c = callback.bind(sender || this._sender);
|
|
105
|
+
c._openglobus_id = callback._openglobus_id;
|
|
106
|
+
c._openglobus_priority = priority;
|
|
107
|
+
binaryInsert(this[name].handlers, c, (a, b) => {
|
|
108
|
+
return b._openglobus_priority - a._openglobus_priority;
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Stop listening event name with specified callback function.
|
|
116
|
+
* @public
|
|
117
|
+
* @param {string} name - Event name.
|
|
118
|
+
* @param {eventCallback} callback - Attached event callback.
|
|
119
|
+
*/
|
|
120
|
+
off(name, callback) {
|
|
121
|
+
if (callback) {
|
|
122
|
+
var st = this._getStamp(name, this.__id, callback._openglobus_id);
|
|
123
|
+
if (callback._openglobus_id && this._stampCache[st]) {
|
|
124
|
+
var h = this[name].handlers;
|
|
125
|
+
var i = h.length;
|
|
126
|
+
var indexToRemove = -1;
|
|
127
|
+
while (i--) {
|
|
128
|
+
var hi = h[i];
|
|
129
|
+
if (hi._openglobus_id === callback._openglobus_id) {
|
|
130
|
+
indexToRemove = i;
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (indexToRemove !== -1) {
|
|
136
|
+
h.splice(indexToRemove, 1);
|
|
137
|
+
this._stampCache[st] = undefined;
|
|
138
|
+
delete this._stampCache[st];
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Dispatch event.
|
|
146
|
+
* @public
|
|
147
|
+
* @param {Object} event - Event instance property that created by event name.
|
|
148
|
+
* @param {Object} [obj] - Event object.
|
|
149
|
+
*/
|
|
150
|
+
dispatch(event, ...args) {
|
|
151
|
+
let result = true;
|
|
152
|
+
if (event && event.active && !this._stopPropagation) {
|
|
153
|
+
let h = event.handlers.slice(0),
|
|
154
|
+
i = h.length;
|
|
155
|
+
while (i--) {
|
|
156
|
+
if (h[i](...args) === false) {
|
|
157
|
+
result = false;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
this._stopPropagation = false;
|
|
162
|
+
return result;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Brakes events propagation.
|
|
167
|
+
* @public
|
|
168
|
+
*/
|
|
169
|
+
stopPropagation() {
|
|
170
|
+
this._stopPropagation = true;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Removes all events.
|
|
175
|
+
* @public
|
|
176
|
+
*/
|
|
177
|
+
clear() {
|
|
178
|
+
for (var i = 0; i < this._eventNames.length; i++) {
|
|
179
|
+
var e = this[this._eventNames[i]];
|
|
180
|
+
e.handlers.length = 0;
|
|
181
|
+
e.handlers = [];
|
|
182
|
+
}
|
|
183
|
+
this._eventNames.length = 0;
|
|
184
|
+
this._eventNames = [];
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export { Events };
|
package/src/og/Extent.js
CHANGED
|
@@ -350,15 +350,7 @@ export class Extent {
|
|
|
350
350
|
|
|
351
351
|
toString() {
|
|
352
352
|
return (
|
|
353
|
-
|
|
354
|
-
this.southWest.lon +
|
|
355
|
-
", " +
|
|
356
|
-
this.southWest.lat +
|
|
357
|
-
", " +
|
|
358
|
-
this.northEast.lon +
|
|
359
|
-
", " +
|
|
360
|
-
this.northEast.lat +
|
|
361
|
-
"]"
|
|
353
|
+
`[${this.southWest.lon.toFixed(5)}, ${this.southWest.lat.toFixed(5)}, ${this.northEast.lon.toFixed(5)}, ${this.northEast.lat.toFixed(5)}]`
|
|
362
354
|
);
|
|
363
355
|
}
|
|
364
356
|
}
|
package/src/og/Globe.js
CHANGED
|
@@ -8,6 +8,7 @@ import { CompassButton } from "./control/CompassButton.js";
|
|
|
8
8
|
import { EarthCoordinates } from "./control/EarthCoordinates.js";
|
|
9
9
|
import { EarthNavigation } from "./control/EarthNavigation.js";
|
|
10
10
|
import { MouseNavigation } from "./control/MouseNavigation.js";
|
|
11
|
+
import { KeyboardNavigation } from "./control/KeyboardNavigation.js";
|
|
11
12
|
import { ScaleControl } from "./control/ScaleControl.js";
|
|
12
13
|
import { Sun } from "./control/Sun.js";
|
|
13
14
|
import { TouchNavigation } from "./control/TouchNavigation.js";
|