deeptwins-engine-3d 0.1.65 → 0.1.67
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/dist/esm/constant.d.ts +10 -0
- package/dist/esm/constant.js +10 -1
- package/dist/esm/drawCommand/viewShed/RectangularSensorPrimitive.d.ts +1 -0
- package/dist/esm/drawCommand/viewShed/ViewShedAnalyserLayer.d.ts +1 -0
- package/dist/esm/drawer/common.d.ts +1 -0
- package/dist/esm/drawer/coordinate.d.ts +1 -0
- package/dist/esm/drawer/index.d.ts +1 -1
- package/dist/esm/drawer/shape/BaseShape.d.ts +1 -0
- package/dist/esm/graphicLayer/BaseLayer.d.ts +23 -0
- package/dist/esm/graphicLayer/BaseLayer.js +387 -65
- package/dist/esm/graphicLayer/BasePrimitiveInstance.d.ts +0 -1
- package/dist/esm/graphicLayer/BasePrimitiveInstance.js +0 -7
- package/dist/esm/graphicLayer/BaseSource.d.ts +1 -1
- package/dist/esm/graphicLayer/BoxPrimitiveInstance.d.ts +0 -1
- package/dist/esm/graphicLayer/BoxPrimitiveInstance.js +4 -8
- package/dist/esm/graphicLayer/EllipsePrimitiveInstance.d.ts +0 -1
- package/dist/esm/graphicLayer/EllipsePrimitiveInstance.js +5 -9
- package/dist/esm/graphicLayer/EllipsoidPrimitiveInstance.d.ts +0 -1
- package/dist/esm/graphicLayer/EllipsoidPrimitiveInstance.js +5 -9
- package/dist/esm/graphicLayer/GraphicLayerCollection.js +20 -27
- package/dist/esm/graphicLayer/ModelPrimitiveInstance.d.ts +0 -1
- package/dist/esm/graphicLayer/ModelPrimitiveInstance.js +0 -7
- package/dist/esm/graphicLayer/PolygonGroundPrimitiveImageMaterialInstance.js +5 -2
- package/dist/esm/graphicLayer/PolygonPrimitiveImageMaterialInstance.js +5 -2
- package/dist/esm/graphicLayer/PolygonPrimitiveInstance.d.ts +0 -1
- package/dist/esm/graphicLayer/PolygonPrimitiveInstance.js +5 -9
- package/dist/esm/graphicLayer/PolylineGroundPrimitiveInstance.d.ts +0 -1
- package/dist/esm/graphicLayer/PolylineGroundPrimitiveInstance.js +4 -8
- package/dist/esm/graphicLayer/PolylinePrimitiveInstance.d.ts +0 -1
- package/dist/esm/graphicLayer/PolylinePrimitiveInstance.js +4 -8
- package/dist/esm/graphicLayer/PolylineVolumePrimitiveInstance.d.ts +0 -1
- package/dist/esm/graphicLayer/PolylineVolumePrimitiveInstance.js +4 -8
- package/dist/esm/graphicLayer/WallPrimitiveInstance.d.ts +0 -1
- package/dist/esm/graphicLayer/WallPrimitiveInstance.js +4 -8
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +6 -2
- package/dist/esm/map/Map.d.ts +9 -0
- package/dist/esm/map/Map.js +115 -2
- package/dist/esm/material/AtmosphericDispersion.d.ts +71 -0
- package/dist/esm/material/AtmosphericDispersion.js +485 -33
- package/dist/esm/material/GlobalVolumetricCloud.d.ts +117 -0
- package/dist/esm/material/GlobalVolumetricCloud.js +219 -223
- package/dist/esm/material/WeatherEffects.d.ts +64 -14
- package/dist/esm/material/WeatherEffects.js +279 -95
- package/dist/esm/material/entity/ImageMaterialProperty.d.ts +1 -0
- package/dist/esm/material/shader/AtmosphericShader.glsl +244 -0
- package/dist/esm/material/shader/RainShader.glsl +44 -6
- package/dist/esm/material/shader/lightning.glsl +70 -0
- package/dist/esm/measure/BaseDraw.d.ts +1 -0
- package/dist/esm/measure/types.d.ts +1 -0
- package/dist/esm/measure/utils.d.ts +1 -0
- package/dist/esm/sceneFusion/Airway.d.ts +0 -0
- package/dist/esm/sceneFusion/Airway.js +692 -0
- package/dist/esm/tileLayer/ArcGisLayer.d.ts +1 -0
- package/dist/esm/tileLayer/ImageryLayer.d.ts +1 -0
- package/dist/esm/tileLayer/MvtVectorLoad.d.ts +13 -0
- package/dist/esm/tileLayer/MvtVectorLoad.js +245 -49
- package/dist/esm/tool/common.d.ts +1 -0
- package/dist/esm/tool/utils.d.ts +1 -0
- package/dist/esm/typings.d.ts +8 -0
- package/dist/esm/visualization/BaseHeatmap.d.ts +5 -0
- package/dist/esm/visualization/BaseHeatmap.js +54 -12
- package/dist/esm/visualization/Heatmap2d.d.ts +1 -0
- package/dist/esm/visualization/Heatmap2d.js +17 -26
- package/dist/esm/visualization/Heatmap3d.d.ts +8 -2
- package/dist/esm/visualization/Heatmap3d.js +195 -59
- package/dist/umd/deeptwins-engine-3d.min.js +1 -1
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference path="../typings.d.ts" />
|
|
1
2
|
import * as Cesium from 'deeptwins-cesium';
|
|
2
3
|
import { MapContext } from '../map/Map';
|
|
3
4
|
type TileState = 'none' | 'loading' | 'loaded' | 'error';
|
|
@@ -151,8 +152,13 @@ declare class MvtVectorLoad {
|
|
|
151
152
|
_tilesToUpdate: VectorLoadTile[];
|
|
152
153
|
_loadedTiles: Record<string, LoadedTile>;
|
|
153
154
|
_pendingTiles: Map<string, Promise<LoadedTile>>;
|
|
155
|
+
private _pendingRequestControllers;
|
|
156
|
+
private _pendingRequestTiles;
|
|
154
157
|
private _cacheOrder;
|
|
155
158
|
_requestToken: number;
|
|
159
|
+
private _requestQueue;
|
|
160
|
+
private _queuedTileKeys;
|
|
161
|
+
private _activeRequestCount;
|
|
156
162
|
private _levelZeroMaximumGeometricError;
|
|
157
163
|
private _decodeWithWorker;
|
|
158
164
|
private _autoDisplayLayers;
|
|
@@ -177,6 +183,9 @@ declare class MvtVectorLoad {
|
|
|
177
183
|
private _doInit;
|
|
178
184
|
private _validateOptions;
|
|
179
185
|
private _emitError;
|
|
186
|
+
private _isAbortError;
|
|
187
|
+
private _markTileLoading;
|
|
188
|
+
private _resetTileRequestState;
|
|
180
189
|
private _createRootTiles;
|
|
181
190
|
private _getTileKey;
|
|
182
191
|
private _touchTileCache;
|
|
@@ -211,11 +220,14 @@ declare class MvtVectorLoad {
|
|
|
211
220
|
private _loadTile;
|
|
212
221
|
tileToGeoJSON(tile: LoadedTile): TileGeoJSONResult;
|
|
213
222
|
update(frameState: FrameStateLike): void;
|
|
223
|
+
private _cancelStaleRequests;
|
|
214
224
|
private _updateTiles;
|
|
225
|
+
private _drainRequestQueue;
|
|
215
226
|
private _loadVisibleTile;
|
|
216
227
|
getLoadedTiles(): LoadedTile[];
|
|
217
228
|
getTile(x: number, y: number, z: number): LoadedTile | undefined;
|
|
218
229
|
clearCache(): void;
|
|
230
|
+
private _abortAllPendingRequests;
|
|
219
231
|
private _resetTileStates;
|
|
220
232
|
destroy(): void;
|
|
221
233
|
isDestroyed(): boolean;
|
|
@@ -233,6 +245,7 @@ declare class VectorLoadTile {
|
|
|
233
245
|
distanceToCamera: number;
|
|
234
246
|
visibility: Cesium.Intersect;
|
|
235
247
|
state: TileState;
|
|
248
|
+
requestVersion: number;
|
|
236
249
|
constructor(options: VectorLoadTileOptions);
|
|
237
250
|
createChildren(): void;
|
|
238
251
|
visit(frameState: FrameStateLike, visitor: TileVisitor, getScreenSpaceError: ScreenSpaceErrorCalculator): void;
|
|
@@ -46,6 +46,9 @@ function createListenerRegistry() {
|
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
// 最大并发请求数,默认 6。
|
|
50
|
+
var MAX_CONCURRENT_TILE_REQUESTS = 6;
|
|
51
|
+
|
|
49
52
|
// 矢量瓦片加载器
|
|
50
53
|
var MvtVectorLoad = /*#__PURE__*/function () {
|
|
51
54
|
function MvtVectorLoad(map) {
|
|
@@ -97,10 +100,20 @@ var MvtVectorLoad = /*#__PURE__*/function () {
|
|
|
97
100
|
_defineProperty(this, "_loadedTiles", void 0);
|
|
98
101
|
// 正在请求中的瓦片 Promise,避免重复请求。
|
|
99
102
|
_defineProperty(this, "_pendingTiles", void 0);
|
|
103
|
+
// 正在执行网络请求的瓦片控制器,用于主动取消过期请求。
|
|
104
|
+
_defineProperty(this, "_pendingRequestControllers", void 0);
|
|
105
|
+
// 正在执行网络请求的瓦片对象,用于回退状态和日志定位。
|
|
106
|
+
_defineProperty(this, "_pendingRequestTiles", void 0);
|
|
100
107
|
// LRU 缓存访问顺序,越靠后表示越新。
|
|
101
108
|
_defineProperty(this, "_cacheOrder", void 0);
|
|
102
109
|
// 请求版本号,用于在清缓存后废弃旧请求结果。
|
|
103
110
|
_defineProperty(this, "_requestToken", void 0);
|
|
111
|
+
// 等待发起请求的瓦片队列,按进入顺序消费。
|
|
112
|
+
_defineProperty(this, "_requestQueue", void 0);
|
|
113
|
+
// 队列中的瓦片 key 集合,避免同一瓦片重复排队。
|
|
114
|
+
_defineProperty(this, "_queuedTileKeys", void 0);
|
|
115
|
+
// 当前已占用的请求槽位数量,限制瞬时并发数。
|
|
116
|
+
_defineProperty(this, "_activeRequestCount", void 0);
|
|
104
117
|
// 第 0 层瓦片的几何误差缓存。
|
|
105
118
|
_defineProperty(this, "_levelZeroMaximumGeometricError", void 0);
|
|
106
119
|
// 是否优先使用 Worker 解析 MVT 二进制。
|
|
@@ -141,8 +154,13 @@ var MvtVectorLoad = /*#__PURE__*/function () {
|
|
|
141
154
|
this._tilesToUpdate = [];
|
|
142
155
|
this._loadedTiles = {};
|
|
143
156
|
this._pendingTiles = new Map();
|
|
157
|
+
this._pendingRequestControllers = new Map();
|
|
158
|
+
this._pendingRequestTiles = new Map();
|
|
144
159
|
this._cacheOrder = new Map();
|
|
145
160
|
this._requestToken = 0;
|
|
161
|
+
this._requestQueue = [];
|
|
162
|
+
this._queuedTileKeys = new Set();
|
|
163
|
+
this._activeRequestCount = 0;
|
|
146
164
|
this._levelZeroMaximumGeometricError = null;
|
|
147
165
|
this._decodeWorkerClient = null;
|
|
148
166
|
this._listenerRegistry = createListenerRegistry();
|
|
@@ -394,6 +412,30 @@ var MvtVectorLoad = /*#__PURE__*/function () {
|
|
|
394
412
|
return error;
|
|
395
413
|
}
|
|
396
414
|
|
|
415
|
+
// 判断错误是否来自 AbortController 主动取消。
|
|
416
|
+
}, {
|
|
417
|
+
key: "_isAbortError",
|
|
418
|
+
value: function _isAbortError(error) {
|
|
419
|
+
return error instanceof Error && error.name === 'AbortError';
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
// 让瓦片进入新的加载批次,并返回本次批次号用于并发回写保护。
|
|
423
|
+
}, {
|
|
424
|
+
key: "_markTileLoading",
|
|
425
|
+
value: function _markTileLoading(tile) {
|
|
426
|
+
tile.requestVersion += 1;
|
|
427
|
+
tile.state = 'loading';
|
|
428
|
+
return tile.requestVersion;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// 让瓦片回到未加载状态,并废弃此前尚未完成的批次回调。
|
|
432
|
+
}, {
|
|
433
|
+
key: "_resetTileRequestState",
|
|
434
|
+
value: function _resetTileRequestState(tile) {
|
|
435
|
+
tile.requestVersion += 1;
|
|
436
|
+
tile.state = 'none';
|
|
437
|
+
}
|
|
438
|
+
|
|
397
439
|
// 创建第 0 层根瓦片,作为后续遍历入口。
|
|
398
440
|
}, {
|
|
399
441
|
key: "_createRootTiles",
|
|
@@ -827,7 +869,7 @@ var MvtVectorLoad = /*#__PURE__*/function () {
|
|
|
827
869
|
for (var index = 0; index < queue.length; index += 1) {
|
|
828
870
|
var _tile6 = queue[index];
|
|
829
871
|
if (keySet.has(_tile6.key)) {
|
|
830
|
-
_tile6
|
|
872
|
+
this._resetTileRequestState(_tile6);
|
|
831
873
|
}
|
|
832
874
|
var _iterator8 = _createForOfIteratorHelper(_tile6.children),
|
|
833
875
|
_step8;
|
|
@@ -952,14 +994,16 @@ var MvtVectorLoad = /*#__PURE__*/function () {
|
|
|
952
994
|
}, {
|
|
953
995
|
key: "_requestTile",
|
|
954
996
|
value: function () {
|
|
955
|
-
var _requestTile2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(x, y, z) {
|
|
997
|
+
var _requestTile2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(x, y, z, signal) {
|
|
956
998
|
var url, response, buffer;
|
|
957
999
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
958
1000
|
while (1) switch (_context3.prev = _context3.next) {
|
|
959
1001
|
case 0:
|
|
960
1002
|
url = this._buildTileUrl(x, y, z);
|
|
961
1003
|
_context3.next = 3;
|
|
962
|
-
return fetch(url
|
|
1004
|
+
return fetch(url, {
|
|
1005
|
+
signal: signal
|
|
1006
|
+
});
|
|
963
1007
|
case 3:
|
|
964
1008
|
response = _context3.sent;
|
|
965
1009
|
if (response.ok) {
|
|
@@ -991,7 +1035,7 @@ var MvtVectorLoad = /*#__PURE__*/function () {
|
|
|
991
1035
|
}
|
|
992
1036
|
}, _callee3, this);
|
|
993
1037
|
}));
|
|
994
|
-
function _requestTile(_x2, _x3, _x4) {
|
|
1038
|
+
function _requestTile(_x2, _x3, _x4, _x5) {
|
|
995
1039
|
return _requestTile2.apply(this, arguments);
|
|
996
1040
|
}
|
|
997
1041
|
return _requestTile;
|
|
@@ -999,9 +1043,9 @@ var MvtVectorLoad = /*#__PURE__*/function () {
|
|
|
999
1043
|
}, {
|
|
1000
1044
|
key: "_loadTile",
|
|
1001
1045
|
value: function () {
|
|
1002
|
-
var _loadTile2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(
|
|
1046
|
+
var _loadTile2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(tile) {
|
|
1003
1047
|
var _this10 = this;
|
|
1004
|
-
var key, cached, pending, requestToken, request;
|
|
1048
|
+
var x, y, z, key, cached, pending, requestToken, controller, request;
|
|
1005
1049
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
1006
1050
|
while (1) switch (_context4.prev = _context4.next) {
|
|
1007
1051
|
case 0:
|
|
@@ -1009,13 +1053,13 @@ var MvtVectorLoad = /*#__PURE__*/function () {
|
|
|
1009
1053
|
return this.init();
|
|
1010
1054
|
case 2:
|
|
1011
1055
|
this._validateOptions();
|
|
1056
|
+
x = tile.x, y = tile.y, z = tile.z, key = tile.key;
|
|
1012
1057
|
if (!(z < this.minzoom || z > this.maximumLevel)) {
|
|
1013
|
-
_context4.next =
|
|
1058
|
+
_context4.next = 6;
|
|
1014
1059
|
break;
|
|
1015
1060
|
}
|
|
1016
1061
|
throw this._emitError(new Error("\u74E6\u7247\u5C42\u7EA7 ".concat(z, " \u8D85\u51FA\u8303\u56F4 [").concat(this.minzoom, ", ").concat(this.maximumLevel, "]")));
|
|
1017
|
-
case
|
|
1018
|
-
key = this._getTileKey(x, y, z);
|
|
1062
|
+
case 6:
|
|
1019
1063
|
cached = this._loadedTiles[key];
|
|
1020
1064
|
if (!cached) {
|
|
1021
1065
|
_context4.next = 10;
|
|
@@ -1033,8 +1077,9 @@ var MvtVectorLoad = /*#__PURE__*/function () {
|
|
|
1033
1077
|
case 13:
|
|
1034
1078
|
// requestToken 用于在 clearCache 后废弃旧请求,避免过期结果再次写回缓存。
|
|
1035
1079
|
requestToken = this._requestToken;
|
|
1036
|
-
|
|
1037
|
-
|
|
1080
|
+
controller = new AbortController();
|
|
1081
|
+
request = this._requestTile(x, y, z, controller.signal).then(function (tile) {
|
|
1082
|
+
if (controller.signal.aborted || requestToken !== _this10._requestToken || _this10._destroyed) {
|
|
1038
1083
|
return tile;
|
|
1039
1084
|
}
|
|
1040
1085
|
_this10._loadedTiles[key] = tile;
|
|
@@ -1044,19 +1089,33 @@ var MvtVectorLoad = /*#__PURE__*/function () {
|
|
|
1044
1089
|
_this10._syncTileDisplayState(_this10._tilesToUpdate);
|
|
1045
1090
|
return tile;
|
|
1046
1091
|
}).catch(function (error) {
|
|
1047
|
-
|
|
1092
|
+
var normalizedError = _this10._toError(error, '加载 MVT 瓦片失败');
|
|
1093
|
+
if (controller.signal.aborted || _this10._isAbortError(normalizedError)) {
|
|
1094
|
+
throw normalizedError;
|
|
1095
|
+
}
|
|
1096
|
+
throw _this10._emitError(normalizedError);
|
|
1048
1097
|
}).finally(function () {
|
|
1049
|
-
_this10._pendingTiles.
|
|
1098
|
+
if (_this10._pendingTiles.get(key) === request) {
|
|
1099
|
+
_this10._pendingTiles.delete(key);
|
|
1100
|
+
}
|
|
1101
|
+
if (_this10._pendingRequestControllers.get(key) === controller) {
|
|
1102
|
+
_this10._pendingRequestControllers.delete(key);
|
|
1103
|
+
}
|
|
1104
|
+
if (_this10._pendingRequestTiles.get(key) === tile) {
|
|
1105
|
+
_this10._pendingRequestTiles.delete(key);
|
|
1106
|
+
}
|
|
1050
1107
|
});
|
|
1051
1108
|
this._pendingTiles.set(key, request);
|
|
1109
|
+
this._pendingRequestControllers.set(key, controller);
|
|
1110
|
+
this._pendingRequestTiles.set(key, tile);
|
|
1052
1111
|
return _context4.abrupt("return", request);
|
|
1053
|
-
case
|
|
1112
|
+
case 20:
|
|
1054
1113
|
case "end":
|
|
1055
1114
|
return _context4.stop();
|
|
1056
1115
|
}
|
|
1057
1116
|
}, _callee4, this);
|
|
1058
1117
|
}));
|
|
1059
|
-
function _loadTile(
|
|
1118
|
+
function _loadTile(_x6) {
|
|
1060
1119
|
return _loadTile2.apply(this, arguments);
|
|
1061
1120
|
}
|
|
1062
1121
|
return _loadTile;
|
|
@@ -1086,59 +1145,163 @@ var MvtVectorLoad = /*#__PURE__*/function () {
|
|
|
1086
1145
|
return;
|
|
1087
1146
|
}
|
|
1088
1147
|
var tilesToUpdate = this._getTilesToUpdate(frameState);
|
|
1148
|
+
var targetTileKeys = new Set(tilesToUpdate.map(function (tile) {
|
|
1149
|
+
return tile.key;
|
|
1150
|
+
}));
|
|
1151
|
+
this._cancelStaleRequests(targetTileKeys);
|
|
1089
1152
|
this._syncTileDisplayState(tilesToUpdate);
|
|
1090
1153
|
this._updateTiles(tilesToUpdate);
|
|
1091
1154
|
}
|
|
1092
1155
|
|
|
1093
|
-
//
|
|
1156
|
+
// 取消当前视口之外的活跃请求,并丢弃尚未发出的过期队列项。
|
|
1094
1157
|
}, {
|
|
1095
|
-
key: "
|
|
1096
|
-
value: function
|
|
1097
|
-
var _iterator9 = _createForOfIteratorHelper(
|
|
1158
|
+
key: "_cancelStaleRequests",
|
|
1159
|
+
value: function _cancelStaleRequests(targetTileKeys) {
|
|
1160
|
+
var _iterator9 = _createForOfIteratorHelper(this._pendingRequestControllers.entries()),
|
|
1098
1161
|
_step9;
|
|
1099
1162
|
try {
|
|
1100
1163
|
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
1101
|
-
var
|
|
1102
|
-
|
|
1164
|
+
var _step9$value = _slicedToArray(_step9.value, 2),
|
|
1165
|
+
key = _step9$value[0],
|
|
1166
|
+
controller = _step9$value[1];
|
|
1167
|
+
if (targetTileKeys.has(key)) {
|
|
1103
1168
|
continue;
|
|
1104
1169
|
}
|
|
1105
|
-
|
|
1170
|
+
var pendingTile = this._pendingRequestTiles.get(key);
|
|
1171
|
+
this._pendingTiles.delete(key);
|
|
1172
|
+
this._pendingRequestControllers.delete(key);
|
|
1173
|
+
this._pendingRequestTiles.delete(key);
|
|
1174
|
+
controller.abort();
|
|
1175
|
+
if (pendingTile) {
|
|
1176
|
+
this._resetTileRequestState(pendingTile);
|
|
1177
|
+
}
|
|
1106
1178
|
}
|
|
1107
1179
|
} catch (err) {
|
|
1108
1180
|
_iterator9.e(err);
|
|
1109
1181
|
} finally {
|
|
1110
1182
|
_iterator9.f();
|
|
1111
1183
|
}
|
|
1184
|
+
if (this._requestQueue.length === 0) {
|
|
1185
|
+
return;
|
|
1186
|
+
}
|
|
1187
|
+
var nextQueue = [];
|
|
1188
|
+
this._queuedTileKeys.clear();
|
|
1189
|
+
var _iterator10 = _createForOfIteratorHelper(this._requestQueue),
|
|
1190
|
+
_step10;
|
|
1191
|
+
try {
|
|
1192
|
+
for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
|
|
1193
|
+
var _tile7 = _step10.value;
|
|
1194
|
+
if (!targetTileKeys.has(_tile7.key)) {
|
|
1195
|
+
this._resetTileRequestState(_tile7);
|
|
1196
|
+
continue;
|
|
1197
|
+
}
|
|
1198
|
+
nextQueue.push(_tile7);
|
|
1199
|
+
this._queuedTileKeys.add(_tile7.key);
|
|
1200
|
+
}
|
|
1201
|
+
} catch (err) {
|
|
1202
|
+
_iterator10.e(err);
|
|
1203
|
+
} finally {
|
|
1204
|
+
_iterator10.f();
|
|
1205
|
+
}
|
|
1206
|
+
this._requestQueue = nextQueue;
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
// 把尚未加载的可见瓦片加入请求队列,并在并发上限内逐个拉起。
|
|
1210
|
+
}, {
|
|
1211
|
+
key: "_updateTiles",
|
|
1212
|
+
value: function _updateTiles(tilesToUpdate) {
|
|
1213
|
+
var _iterator11 = _createForOfIteratorHelper(tilesToUpdate),
|
|
1214
|
+
_step11;
|
|
1215
|
+
try {
|
|
1216
|
+
for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
|
|
1217
|
+
var _tile8 = _step11.value;
|
|
1218
|
+
if (_tile8.state !== 'none') {
|
|
1219
|
+
continue;
|
|
1220
|
+
}
|
|
1221
|
+
this._markTileLoading(_tile8);
|
|
1222
|
+
this._requestQueue.push(_tile8);
|
|
1223
|
+
this._queuedTileKeys.add(_tile8.key);
|
|
1224
|
+
}
|
|
1225
|
+
} catch (err) {
|
|
1226
|
+
_iterator11.e(err);
|
|
1227
|
+
} finally {
|
|
1228
|
+
_iterator11.f();
|
|
1229
|
+
}
|
|
1230
|
+
this._drainRequestQueue();
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
// 在固定并发数内消费排队中的瓦片请求。
|
|
1234
|
+
}, {
|
|
1235
|
+
key: "_drainRequestQueue",
|
|
1236
|
+
value: function _drainRequestQueue() {
|
|
1237
|
+
var _this11 = this;
|
|
1238
|
+
if (this._destroyed) {
|
|
1239
|
+
return;
|
|
1240
|
+
}
|
|
1241
|
+
while (this._activeRequestCount < MAX_CONCURRENT_TILE_REQUESTS && this._requestQueue.length > 0) {
|
|
1242
|
+
var _tile9 = this._requestQueue.shift();
|
|
1243
|
+
if (!_tile9) {
|
|
1244
|
+
continue;
|
|
1245
|
+
}
|
|
1246
|
+
this._queuedTileKeys.delete(_tile9.key);
|
|
1247
|
+
if (_tile9.state !== 'loading') {
|
|
1248
|
+
continue;
|
|
1249
|
+
}
|
|
1250
|
+
var requestVersion = _tile9.requestVersion;
|
|
1251
|
+
this._activeRequestCount += 1;
|
|
1252
|
+
void this._loadVisibleTile(_tile9, requestVersion).finally(function () {
|
|
1253
|
+
_this11._activeRequestCount = Math.max(_this11._activeRequestCount - 1, 0);
|
|
1254
|
+
_this11._drainRequestQueue();
|
|
1255
|
+
});
|
|
1256
|
+
}
|
|
1112
1257
|
}
|
|
1113
1258
|
|
|
1114
1259
|
// 加载当前可见瓦片,并同步维护瓦片状态。
|
|
1115
1260
|
}, {
|
|
1116
1261
|
key: "_loadVisibleTile",
|
|
1117
1262
|
value: function () {
|
|
1118
|
-
var _loadVisibleTile2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(tile) {
|
|
1263
|
+
var _loadVisibleTile2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(tile, requestVersion) {
|
|
1119
1264
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
1120
1265
|
while (1) switch (_context5.prev = _context5.next) {
|
|
1121
1266
|
case 0:
|
|
1122
|
-
|
|
1123
|
-
_context5.
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1267
|
+
_context5.prev = 0;
|
|
1268
|
+
_context5.next = 3;
|
|
1269
|
+
return this._loadTile(tile);
|
|
1270
|
+
case 3:
|
|
1271
|
+
if (!(tile.requestVersion !== requestVersion)) {
|
|
1272
|
+
_context5.next = 5;
|
|
1273
|
+
break;
|
|
1274
|
+
}
|
|
1275
|
+
return _context5.abrupt("return");
|
|
1276
|
+
case 5:
|
|
1127
1277
|
tile.state = 'loaded';
|
|
1128
|
-
_context5.next =
|
|
1278
|
+
_context5.next = 17;
|
|
1129
1279
|
break;
|
|
1130
|
-
case
|
|
1131
|
-
_context5.prev =
|
|
1132
|
-
_context5.t0 = _context5["catch"](
|
|
1280
|
+
case 8:
|
|
1281
|
+
_context5.prev = 8;
|
|
1282
|
+
_context5.t0 = _context5["catch"](0);
|
|
1283
|
+
if (!(tile.requestVersion !== requestVersion)) {
|
|
1284
|
+
_context5.next = 12;
|
|
1285
|
+
break;
|
|
1286
|
+
}
|
|
1287
|
+
return _context5.abrupt("return");
|
|
1288
|
+
case 12:
|
|
1289
|
+
if (!this._isAbortError(_context5.t0)) {
|
|
1290
|
+
_context5.next = 15;
|
|
1291
|
+
break;
|
|
1292
|
+
}
|
|
1293
|
+
tile.state = 'none';
|
|
1294
|
+
return _context5.abrupt("return");
|
|
1295
|
+
case 15:
|
|
1133
1296
|
tile.state = 'error';
|
|
1134
1297
|
console.error("\u52A0\u8F7D\u5931\u8D25 [".concat(tile.x, ", ").concat(tile.y, ", ").concat(tile.z, "]"), _context5.t0);
|
|
1135
|
-
case
|
|
1298
|
+
case 17:
|
|
1136
1299
|
case "end":
|
|
1137
1300
|
return _context5.stop();
|
|
1138
1301
|
}
|
|
1139
|
-
}, _callee5, this, [[
|
|
1302
|
+
}, _callee5, this, [[0, 8]]);
|
|
1140
1303
|
}));
|
|
1141
|
-
function _loadVisibleTile(_x8) {
|
|
1304
|
+
function _loadVisibleTile(_x7, _x8) {
|
|
1142
1305
|
return _loadVisibleTile2.apply(this, arguments);
|
|
1143
1306
|
}
|
|
1144
1307
|
return _loadVisibleTile;
|
|
@@ -1162,15 +1325,16 @@ var MvtVectorLoad = /*#__PURE__*/function () {
|
|
|
1162
1325
|
value: function clearCache() {
|
|
1163
1326
|
this._requestToken += 1;
|
|
1164
1327
|
var cachedTiles = Object.values(this._loadedTiles);
|
|
1328
|
+
this._abortAllPendingRequests();
|
|
1165
1329
|
this._hideAllDisplayedTiles();
|
|
1166
1330
|
for (var _i4 = 0, _cachedTiles = cachedTiles; _i4 < _cachedTiles.length; _i4++) {
|
|
1167
|
-
var
|
|
1168
|
-
var key = this._getTileKey(
|
|
1331
|
+
var _tile10 = _cachedTiles[_i4];
|
|
1332
|
+
var key = this._getTileKey(_tile10.x, _tile10.y, _tile10.z);
|
|
1169
1333
|
this.tileEvictEvent.raiseEvent({
|
|
1170
1334
|
key: key,
|
|
1171
|
-
x:
|
|
1172
|
-
y:
|
|
1173
|
-
z:
|
|
1335
|
+
x: _tile10.x,
|
|
1336
|
+
y: _tile10.y,
|
|
1337
|
+
z: _tile10.z
|
|
1174
1338
|
});
|
|
1175
1339
|
this._removeManagedTileLayers(key);
|
|
1176
1340
|
}
|
|
@@ -1181,28 +1345,57 @@ var MvtVectorLoad = /*#__PURE__*/function () {
|
|
|
1181
1345
|
this._resetTileStates();
|
|
1182
1346
|
}
|
|
1183
1347
|
|
|
1348
|
+
// 取消全部进行中与排队中的请求,供清缓存和销毁时统一复用。
|
|
1349
|
+
}, {
|
|
1350
|
+
key: "_abortAllPendingRequests",
|
|
1351
|
+
value: function _abortAllPendingRequests() {
|
|
1352
|
+
this._requestQueue.length = 0;
|
|
1353
|
+
this._queuedTileKeys.clear();
|
|
1354
|
+
var _iterator12 = _createForOfIteratorHelper(this._pendingRequestControllers.entries()),
|
|
1355
|
+
_step12;
|
|
1356
|
+
try {
|
|
1357
|
+
for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
|
|
1358
|
+
var _step12$value = _slicedToArray(_step12.value, 2),
|
|
1359
|
+
key = _step12$value[0],
|
|
1360
|
+
controller = _step12$value[1];
|
|
1361
|
+
var pendingTile = this._pendingRequestTiles.get(key);
|
|
1362
|
+
this._pendingTiles.delete(key);
|
|
1363
|
+
this._pendingRequestControllers.delete(key);
|
|
1364
|
+
this._pendingRequestTiles.delete(key);
|
|
1365
|
+
controller.abort();
|
|
1366
|
+
if (pendingTile) {
|
|
1367
|
+
this._resetTileRequestState(pendingTile);
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
} catch (err) {
|
|
1371
|
+
_iterator12.e(err);
|
|
1372
|
+
} finally {
|
|
1373
|
+
_iterator12.f();
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
|
|
1184
1377
|
// 把整棵瓦片树的状态恢复为未加载。
|
|
1185
1378
|
}, {
|
|
1186
1379
|
key: "_resetTileStates",
|
|
1187
1380
|
value: function _resetTileStates() {
|
|
1188
1381
|
var queue = _toConsumableArray(this._rootTiles);
|
|
1189
1382
|
while (queue.length > 0) {
|
|
1190
|
-
var
|
|
1191
|
-
if (!
|
|
1383
|
+
var _tile11 = queue.shift();
|
|
1384
|
+
if (!_tile11) {
|
|
1192
1385
|
continue;
|
|
1193
1386
|
}
|
|
1194
|
-
|
|
1195
|
-
var
|
|
1196
|
-
|
|
1387
|
+
this._resetTileRequestState(_tile11);
|
|
1388
|
+
var _iterator13 = _createForOfIteratorHelper(_tile11.children),
|
|
1389
|
+
_step13;
|
|
1197
1390
|
try {
|
|
1198
|
-
for (
|
|
1199
|
-
var child =
|
|
1391
|
+
for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
|
|
1392
|
+
var child = _step13.value;
|
|
1200
1393
|
queue.push(child);
|
|
1201
1394
|
}
|
|
1202
1395
|
} catch (err) {
|
|
1203
|
-
|
|
1396
|
+
_iterator13.e(err);
|
|
1204
1397
|
} finally {
|
|
1205
|
-
|
|
1398
|
+
_iterator13.f();
|
|
1206
1399
|
}
|
|
1207
1400
|
}
|
|
1208
1401
|
}
|
|
@@ -1263,6 +1456,8 @@ var VectorLoadTile = /*#__PURE__*/function () {
|
|
|
1263
1456
|
_defineProperty(this, "visibility", void 0);
|
|
1264
1457
|
// 当前瓦片的加载状态。
|
|
1265
1458
|
_defineProperty(this, "state", void 0);
|
|
1459
|
+
// 当前瓦片的请求批次号,用于丢弃过期的异步回写。
|
|
1460
|
+
_defineProperty(this, "requestVersion", void 0);
|
|
1266
1461
|
this.x = options.x;
|
|
1267
1462
|
this.y = options.y;
|
|
1268
1463
|
this.z = options.z;
|
|
@@ -1281,6 +1476,7 @@ var VectorLoadTile = /*#__PURE__*/function () {
|
|
|
1281
1476
|
this.distanceToCamera = 0;
|
|
1282
1477
|
this.visibility = Cesium.Intersect.INSIDE;
|
|
1283
1478
|
this.state = 'none';
|
|
1479
|
+
this.requestVersion = 0;
|
|
1284
1480
|
}
|
|
1285
1481
|
|
|
1286
1482
|
// 创建四个子瓦片;如果已经创建过则直接返回。
|
package/dist/esm/tool/utils.d.ts
CHANGED
package/dist/esm/typings.d.ts
CHANGED
|
@@ -13,3 +13,11 @@ declare const VERSION: string;
|
|
|
13
13
|
// 在esm中会赋值给window.CESIUM_BASE_URL 使用本地代理
|
|
14
14
|
// 在umd中会使用https://unpkg.com上相应版本的地址
|
|
15
15
|
declare const DEEP_TWINS_BASE_URL: string;
|
|
16
|
+
declare module 'deeptwins-cesium' {
|
|
17
|
+
export const BufferUsage: any;
|
|
18
|
+
export const DrawCommand: any;
|
|
19
|
+
export const Pass: any;
|
|
20
|
+
export const RenderState: any;
|
|
21
|
+
export const ShaderProgram: any;
|
|
22
|
+
export const VertexArray: any;
|
|
23
|
+
}
|