@openglobus/og 0.13.4 → 0.13.7
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/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/TouchNavigation.js +13 -13
- package/src/og/control/ZoomControl.js +1 -1
- package/src/og/ellipsoid/Ellipsoid.js +1 -1
- package/src/og/entity/Billboard.js +165 -165
- package/src/og/entity/BillboardHandler.js +1 -1
- package/src/og/entity/Geometry.js +319 -319
- package/src/og/entity/Label.js +348 -346
- package/src/og/entity/LabelHandler.js +44 -37
- 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 +4 -2
- package/src/og/layer/XYZ.js +4 -2
- package/src/og/quadTree/Node.js +1 -0
- package/src/og/renderer/RendererEvents.js +17 -3
- package/src/og/scene/Planet.js +89 -30
- package/src/og/segment/Segment.js +1 -0
- package/src/og/shaders/label.js +56 -13
- 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 +25 -15
- package/src/og/utils/Loader.js +53 -12
- package/src/og/utils/PlainSegmentWorker.js +38 -26
- package/src/og/utils/TextureAtlas.js +291 -280
- package/src/og/utils/units.js +78 -0
- package/types/control/EarthCoordinates.d.ts +27 -30
- package/types/control/KeyboardNavigation.d.ts +3 -0
- package/types/entity/Label.d.ts +1 -0
- package/types/entity/LabelHandler.d.ts +1 -1
- package/types/input/input.d.ts +6 -0
- package/types/layer/KML.d.ts +26 -1
- package/types/renderer/RendererEvents.d.ts +2 -0
- package/types/scene/Planet.d.ts +10 -1
- 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 +3 -0
- package/types/utils/TextureAtlas.d.ts +2 -0
- package/types/utils/units.d.ts +20 -0
package/src/og/utils/Loader.js
CHANGED
|
@@ -26,6 +26,8 @@ export class Loader {
|
|
|
26
26
|
|
|
27
27
|
this._queue = [];//new QueueArray();
|
|
28
28
|
|
|
29
|
+
this._senderRequestCounter = [];
|
|
30
|
+
|
|
29
31
|
this._promises = {
|
|
30
32
|
'json': r => r.json(),
|
|
31
33
|
'blob': r => r.blob(),
|
|
@@ -36,6 +38,16 @@ export class Loader {
|
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
load(params, callback) {
|
|
41
|
+
if (params.sender) {
|
|
42
|
+
if (!this._senderRequestCounter[params.sender._id]) {
|
|
43
|
+
this._senderRequestCounter[params.sender._id] = {
|
|
44
|
+
sender: params.sender,
|
|
45
|
+
counter: 0,
|
|
46
|
+
__requestCounterFrame__: null
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
this._senderRequestCounter[params.sender._id].counter++;
|
|
50
|
+
}
|
|
39
51
|
this._queue.push({ 'params': params, 'callback': callback });
|
|
40
52
|
this._exec();
|
|
41
53
|
}
|
|
@@ -43,8 +55,8 @@ export class Loader {
|
|
|
43
55
|
fetch(params) {
|
|
44
56
|
return fetch(
|
|
45
57
|
params.src,
|
|
46
|
-
params.options || {}
|
|
47
|
-
|
|
58
|
+
params.options || {}
|
|
59
|
+
)
|
|
48
60
|
.then(response => {
|
|
49
61
|
if (!response.ok) {
|
|
50
62
|
throw Error(`Unable to load '${params.src}'`);
|
|
@@ -62,6 +74,33 @@ export class Loader {
|
|
|
62
74
|
});
|
|
63
75
|
}
|
|
64
76
|
|
|
77
|
+
_checkLoadend(request, sender) {
|
|
78
|
+
if (request.counter === 0 && sender._planet._terrainCompletedActivated) {
|
|
79
|
+
sender.events.dispatch(sender.events.loadend);
|
|
80
|
+
request.__requestCounterFrame__ = null;
|
|
81
|
+
} else {
|
|
82
|
+
request.__requestCounterFrame__ = requestAnimationFrame(() => {
|
|
83
|
+
this._checkLoadend(request, sender);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
_handleResponse(q, response) {
|
|
89
|
+
q.callback(response);
|
|
90
|
+
let sender = q.params.sender;
|
|
91
|
+
if (sender && sender.events.loadend.handlers.length) {
|
|
92
|
+
let request = this._senderRequestCounter[sender._id];
|
|
93
|
+
if (request && request.counter > 0) {
|
|
94
|
+
request.counter--;
|
|
95
|
+
cancelAnimationFrame(request.__requestCounterFrame__);
|
|
96
|
+
request.__requestCounterFrame__ = requestAnimationFrame(() => {
|
|
97
|
+
this._checkLoadend(request, sender);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
this._exec();
|
|
102
|
+
}
|
|
103
|
+
|
|
65
104
|
_exec() {
|
|
66
105
|
|
|
67
106
|
if (this._queue.length > 0 && this._loading < this.MAX_REQUESTS) {
|
|
@@ -82,18 +121,15 @@ export class Loader {
|
|
|
82
121
|
})
|
|
83
122
|
.then(data => {
|
|
84
123
|
this._loading--;
|
|
85
|
-
|
|
86
|
-
this._exec();
|
|
124
|
+
this._handleResponse(q, { status: "ready", data: data });
|
|
87
125
|
})
|
|
88
126
|
.catch(err => {
|
|
89
127
|
this._loading--;
|
|
90
|
-
|
|
91
|
-
this._exec();
|
|
128
|
+
this._handleResponse(q, { status: "error", msg: err.toString() });
|
|
92
129
|
});
|
|
93
130
|
|
|
94
131
|
} else {
|
|
95
|
-
|
|
96
|
-
this._exec();
|
|
132
|
+
this._handleResponse(q, { status: "abort" });
|
|
97
133
|
}
|
|
98
134
|
} else if (this._loading === 0) {
|
|
99
135
|
this.events.dispatch(this.events.loadend);
|
|
@@ -101,13 +137,18 @@ export class Loader {
|
|
|
101
137
|
}
|
|
102
138
|
|
|
103
139
|
abort() {
|
|
104
|
-
//this._queue.each(e => e.callback({ 'status': "abort" }));
|
|
105
|
-
//this._queue.clear();
|
|
106
|
-
|
|
107
140
|
for (let i = 0, len = this._queue.length; i < len; i++) {
|
|
108
|
-
this._queue[i]
|
|
141
|
+
let qi = this._queue[i];
|
|
142
|
+
let sender = qi.params.sender;
|
|
143
|
+
if (sender && this._senderRequestCounter[sender._id]) {
|
|
144
|
+
this._senderRequestCounter[sender._id].counter = 0;
|
|
145
|
+
cancelAnimationFrame(this._senderRequestCounter[sender._id].__requestCounterFrame__);
|
|
146
|
+
this._senderRequestCounter[sender._id].__requestCounterFrame__ = null;
|
|
147
|
+
}
|
|
148
|
+
qi.callback({ 'status': "abort" });
|
|
109
149
|
this._queue[i] = null;
|
|
110
150
|
}
|
|
111
151
|
this._queue = [];
|
|
152
|
+
this._loading === 0;
|
|
112
153
|
}
|
|
113
154
|
}
|
|
@@ -49,30 +49,42 @@ class PlainSegmentWorker {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
setGeoid(geoid) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
52
|
+
|
|
53
|
+
let model = null;
|
|
54
|
+
|
|
55
|
+
if (geoid.model) {
|
|
56
|
+
let m = geoid.model;
|
|
57
|
+
model = {
|
|
58
|
+
scale: m.scale,
|
|
59
|
+
offset: m.offset,
|
|
60
|
+
width: m.width,
|
|
61
|
+
height: m.height,
|
|
62
|
+
rlonres: m.rlonres,
|
|
63
|
+
rlatres: m.rlatres,
|
|
64
|
+
i: m.i
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
this._workerQueue.forEach((w) => {
|
|
68
|
+
let rawfile = new Uint8Array(m.rawfile.length);
|
|
69
|
+
rawfile.set(m.rawfile);
|
|
70
|
+
|
|
71
|
+
w.postMessage(
|
|
72
|
+
{
|
|
73
|
+
model: model,
|
|
74
|
+
rawfile: rawfile
|
|
75
|
+
},
|
|
76
|
+
[rawfile.buffer]
|
|
77
|
+
);
|
|
78
|
+
});
|
|
79
|
+
} else {
|
|
80
|
+
this._workerQueue.forEach((w) => {
|
|
81
|
+
w.postMessage(
|
|
82
|
+
{
|
|
83
|
+
model: null
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
76
88
|
}
|
|
77
89
|
|
|
78
90
|
make(segment) {
|
|
@@ -116,6 +128,8 @@ class PlainSegmentWorker {
|
|
|
116
128
|
|
|
117
129
|
const _programm = `
|
|
118
130
|
'use strict';
|
|
131
|
+
|
|
132
|
+
let model = null;
|
|
119
133
|
|
|
120
134
|
let cached_ix = null;
|
|
121
135
|
let cached_iy = null;
|
|
@@ -185,8 +199,6 @@ const _programm = `
|
|
|
185
199
|
return model.offset + model.scale * h;
|
|
186
200
|
};
|
|
187
201
|
|
|
188
|
-
let model = null;
|
|
189
|
-
|
|
190
202
|
const HALF_PI = Math.PI * 0.5;
|
|
191
203
|
const POLE = 20037508.34;
|
|
192
204
|
const PI_BY_POLE = Math.PI / POLE;
|