@antv/l7-scene 2.20.20 → 2.21.1
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/es/index.d.ts +5 -4
- package/es/index.js +56 -28
- package/lib/index.js +37 -24
- package/package.json +18 -20
package/es/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { Bounds, ICameraOptions, IControl, IDebugService, IIconFontGlyph, IImage, ILayer, ILngLat, IMapService, IMarker, IMarkerLayer, IPoint, IPopup, IPostProcessingPass, ISceneConfig, IStatusOptions, Point } from '@antv/l7-core';
|
|
1
|
+
import type { Bounds, ICameraOptions, IControl, IDebugService, IIconFontGlyph, IImage, ILayer, ILngLat, IMapService, IMarker, IMarkerLayer, IPoint, IPopup, IPostProcessingPass, ISceneConfig, IStatusOptions, Point, L7Container } from '@antv/l7-core';
|
|
2
2
|
import type { IProtocolHandler } from '@antv/l7-utils';
|
|
3
|
-
import type { Container } from 'inversify';
|
|
4
3
|
import type ILayerManager from './ILayerManager';
|
|
5
4
|
import type IMapController from './IMapController';
|
|
6
5
|
import type IPostProcessingPassPluggable from './IPostProcessingPassPluggable';
|
|
@@ -32,7 +31,7 @@ declare class Scene implements IPostProcessingPassPluggable, IMapController, ILa
|
|
|
32
31
|
constructor(config: ISceneConfig);
|
|
33
32
|
get map(): unknown;
|
|
34
33
|
get loaded(): boolean;
|
|
35
|
-
getServiceContainer():
|
|
34
|
+
getServiceContainer(): L7Container;
|
|
36
35
|
getSize(): [number, number];
|
|
37
36
|
getMinZoom(): number;
|
|
38
37
|
getMaxZoom(): number;
|
|
@@ -50,6 +49,7 @@ declare class Scene implements IPostProcessingPassPluggable, IMapController, ILa
|
|
|
50
49
|
registerRenderService(render: any): void;
|
|
51
50
|
setBgColor(color: string): void;
|
|
52
51
|
addLayer(layer: ILayer): void;
|
|
52
|
+
preAddLayer(layer: ILayer): void;
|
|
53
53
|
initMask(layer: ILayer): ILayer | undefined;
|
|
54
54
|
addMask(mask: ILayer, layerId: string): void;
|
|
55
55
|
getPickedLayer(): number;
|
|
@@ -114,7 +114,7 @@ declare class Scene implements IPostProcessingPassPluggable, IMapController, ILa
|
|
|
114
114
|
containerToLngLat(pixel: Point): ILngLat;
|
|
115
115
|
lngLatToContainer(lnglat: Point): IPoint;
|
|
116
116
|
destroy(): void;
|
|
117
|
-
registerPostProcessingPass(constructor: new (...args: any[]) => IPostProcessingPass<unknown
|
|
117
|
+
registerPostProcessingPass(constructor: new (...args: any[]) => IPostProcessingPass<unknown>): void;
|
|
118
118
|
enableShaderPick(): void;
|
|
119
119
|
diasbleShaderPick(): void;
|
|
120
120
|
enableBoxSelect(once?: boolean): void;
|
|
@@ -127,5 +127,6 @@ declare class Scene implements IPostProcessingPassPluggable, IMapController, ILa
|
|
|
127
127
|
getPointSizeRange(): Float32Array;
|
|
128
128
|
private initComponent;
|
|
129
129
|
private initControl;
|
|
130
|
+
private initTileLayer;
|
|
130
131
|
}
|
|
131
132
|
export { Scene };
|
package/es/index.js
CHANGED
|
@@ -5,11 +5,12 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
|
5
5
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
6
6
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
7
7
|
import { Logo } from '@antv/l7-component';
|
|
8
|
-
import { createLayerContainer, createSceneContainer
|
|
9
|
-
import { MaskLayer } from '@antv/l7-layers';
|
|
8
|
+
import { SceneEventList, createLayerContainer, createSceneContainer } from '@antv/l7-core';
|
|
9
|
+
import { MaskLayer, TileLayer } from '@antv/l7-layers';
|
|
10
10
|
import { DeviceRendererService, ReglRendererService } from '@antv/l7-renderer';
|
|
11
11
|
import { DOM, SceneConifg } from '@antv/l7-utils';
|
|
12
12
|
import BoxSelect, { BoxSelectEventList } from "./boxSelect";
|
|
13
|
+
|
|
13
14
|
/**
|
|
14
15
|
* 暴露 Scene API
|
|
15
16
|
*
|
|
@@ -35,21 +36,24 @@ var Scene = /*#__PURE__*/function () {
|
|
|
35
36
|
this.container = sceneContainer;
|
|
36
37
|
// 绑定地图服务
|
|
37
38
|
map.setContainer(sceneContainer, id, canvas);
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
if (renderer === 'regl') {
|
|
40
|
+
sceneContainer.rendererService = new ReglRendererService();
|
|
41
|
+
} else {
|
|
42
|
+
sceneContainer.rendererService = new DeviceRendererService();
|
|
43
|
+
}
|
|
40
44
|
|
|
41
45
|
// 依赖注入
|
|
42
|
-
this.sceneService = sceneContainer.
|
|
43
|
-
this.mapService = sceneContainer.
|
|
44
|
-
this.iconService = sceneContainer.
|
|
45
|
-
this.fontService = sceneContainer.
|
|
46
|
-
this.controlService = sceneContainer.
|
|
47
|
-
this.layerService = sceneContainer.
|
|
48
|
-
this.debugService = sceneContainer.
|
|
46
|
+
this.sceneService = sceneContainer.sceneService;
|
|
47
|
+
this.mapService = sceneContainer.mapService;
|
|
48
|
+
this.iconService = sceneContainer.iconService;
|
|
49
|
+
this.fontService = sceneContainer.fontService;
|
|
50
|
+
this.controlService = sceneContainer.controlService;
|
|
51
|
+
this.layerService = sceneContainer.layerService;
|
|
52
|
+
this.debugService = sceneContainer.debugService;
|
|
49
53
|
this.debugService.setEnable(config.debug);
|
|
50
|
-
this.markerService = sceneContainer.
|
|
51
|
-
this.interactionService = sceneContainer.
|
|
52
|
-
this.popupService = sceneContainer.
|
|
54
|
+
this.markerService = sceneContainer.markerService;
|
|
55
|
+
this.interactionService = sceneContainer.interactionService;
|
|
56
|
+
this.popupService = sceneContainer.popupService;
|
|
53
57
|
this.boxSelect = new BoxSelect(this, {});
|
|
54
58
|
this.initComponent(id);
|
|
55
59
|
|
|
@@ -176,29 +180,45 @@ var Scene = /*#__PURE__*/function () {
|
|
|
176
180
|
value: function setBgColor(color) {
|
|
177
181
|
this.mapService.setBgColor(color);
|
|
178
182
|
}
|
|
179
|
-
|
|
180
|
-
// layer 管理
|
|
181
183
|
}, {
|
|
182
184
|
key: "addLayer",
|
|
183
185
|
value: function addLayer(layer) {
|
|
184
186
|
var _this2 = this;
|
|
187
|
+
if (this.loaded) {
|
|
188
|
+
this.preAddLayer(layer);
|
|
189
|
+
} else {
|
|
190
|
+
this.once('loaded', function () {
|
|
191
|
+
_this2.preAddLayer(layer);
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// layer 管理
|
|
197
|
+
}, {
|
|
198
|
+
key: "preAddLayer",
|
|
199
|
+
value: function preAddLayer(layer) {
|
|
200
|
+
var _this3 = this;
|
|
185
201
|
// 为当前图层创建一个容器
|
|
186
202
|
// TODO: 初始化的时候设置 容器
|
|
187
203
|
var layerContainer = createLayerContainer(this.container);
|
|
188
|
-
layer.setContainer(layerContainer
|
|
204
|
+
layer.setContainer(layerContainer);
|
|
189
205
|
this.sceneService.addLayer(layer);
|
|
190
206
|
|
|
191
207
|
// mask 在 scene loaded 之后执行
|
|
192
208
|
if (layer.inited) {
|
|
209
|
+
this.initTileLayer(layer);
|
|
210
|
+
// 全局mask
|
|
193
211
|
var maskInstance = this.initMask(layer);
|
|
194
212
|
this.addMask(maskInstance, layer.id);
|
|
195
213
|
} else {
|
|
196
214
|
layer.on('inited', function () {
|
|
197
|
-
|
|
198
|
-
|
|
215
|
+
_this3.initTileLayer(layer);
|
|
216
|
+
var maskInstance = _this3.initMask(layer); // 初始化 mask
|
|
217
|
+
_this3.addMask(maskInstance, layer.id);
|
|
199
218
|
});
|
|
200
219
|
}
|
|
201
220
|
}
|
|
221
|
+
// 兼容历史接口
|
|
202
222
|
}, {
|
|
203
223
|
key: "initMask",
|
|
204
224
|
value: function initMask(layer) {
|
|
@@ -227,7 +247,7 @@ var Scene = /*#__PURE__*/function () {
|
|
|
227
247
|
var parent = this.getLayer(layerId);
|
|
228
248
|
if (parent) {
|
|
229
249
|
var layerContainer = createLayerContainer(this.container);
|
|
230
|
-
mask.setContainer(layerContainer
|
|
250
|
+
mask.setContainer(layerContainer);
|
|
231
251
|
parent.addMaskLayer(mask);
|
|
232
252
|
this.sceneService.addMask(mask);
|
|
233
253
|
} else {
|
|
@@ -319,12 +339,12 @@ var Scene = /*#__PURE__*/function () {
|
|
|
319
339
|
}, {
|
|
320
340
|
key: "addIconFonts",
|
|
321
341
|
value: function addIconFonts(options) {
|
|
322
|
-
var
|
|
342
|
+
var _this4 = this;
|
|
323
343
|
options.forEach(function (_ref) {
|
|
324
344
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
325
345
|
name = _ref2[0],
|
|
326
346
|
fontUnicode = _ref2[1];
|
|
327
|
-
|
|
347
|
+
_this4.fontService.addIconFont(name, fontUnicode);
|
|
328
348
|
});
|
|
329
349
|
}
|
|
330
350
|
/**
|
|
@@ -335,9 +355,9 @@ var Scene = /*#__PURE__*/function () {
|
|
|
335
355
|
}, {
|
|
336
356
|
key: "addFontFace",
|
|
337
357
|
value: function addFontFace(fontFamily, fontPath) {
|
|
338
|
-
var
|
|
358
|
+
var _this5 = this;
|
|
339
359
|
this.fontService.once('fontloaded', function (e) {
|
|
340
|
-
|
|
360
|
+
_this5.emit('fontloaded', e);
|
|
341
361
|
});
|
|
342
362
|
this.fontService.addFontFace(fontFamily, fontPath);
|
|
343
363
|
}
|
|
@@ -601,8 +621,8 @@ var Scene = /*#__PURE__*/function () {
|
|
|
601
621
|
}
|
|
602
622
|
}, {
|
|
603
623
|
key: "registerPostProcessingPass",
|
|
604
|
-
value: function registerPostProcessingPass(constructor
|
|
605
|
-
this.container.
|
|
624
|
+
value: function registerPostProcessingPass(constructor) {
|
|
625
|
+
this.container.postProcessingPass.name = new constructor();
|
|
606
626
|
}
|
|
607
627
|
|
|
608
628
|
// 控制 shader pick 计算
|
|
@@ -619,12 +639,12 @@ var Scene = /*#__PURE__*/function () {
|
|
|
619
639
|
}, {
|
|
620
640
|
key: "enableBoxSelect",
|
|
621
641
|
value: function enableBoxSelect() {
|
|
622
|
-
var
|
|
642
|
+
var _this6 = this;
|
|
623
643
|
var once = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
624
644
|
this.boxSelect.enable();
|
|
625
645
|
if (once) {
|
|
626
646
|
this.boxSelect.once('selectend', function () {
|
|
627
|
-
|
|
647
|
+
_this6.disableBoxSelect();
|
|
628
648
|
});
|
|
629
649
|
}
|
|
630
650
|
}
|
|
@@ -678,6 +698,14 @@ var Scene = /*#__PURE__*/function () {
|
|
|
678
698
|
}));
|
|
679
699
|
}
|
|
680
700
|
}
|
|
701
|
+
}, {
|
|
702
|
+
key: "initTileLayer",
|
|
703
|
+
value: function initTileLayer(layer) {
|
|
704
|
+
if (layer.getSource().isTile) {
|
|
705
|
+
layer.tileLayer = new TileLayer(layer);
|
|
706
|
+
// Todo 支持瓦片更新
|
|
707
|
+
}
|
|
708
|
+
}
|
|
681
709
|
}], [{
|
|
682
710
|
key: "addProtocol",
|
|
683
711
|
value: function addProtocol(protocol, handler) {
|
package/lib/index.js
CHANGED
|
@@ -44,26 +44,22 @@ var Scene = class {
|
|
|
44
44
|
const sceneContainer = (0, import_l7_core.createSceneContainer)();
|
|
45
45
|
this.container = sceneContainer;
|
|
46
46
|
map.setContainer(sceneContainer, id, canvas);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
this.
|
|
53
|
-
this.
|
|
54
|
-
this.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
this.layerService = sceneContainer.
|
|
58
|
-
this.debugService = sceneContainer.
|
|
47
|
+
if (renderer === "regl") {
|
|
48
|
+
sceneContainer.rendererService = new import_l7_renderer.ReglRendererService();
|
|
49
|
+
} else {
|
|
50
|
+
sceneContainer.rendererService = new import_l7_renderer.DeviceRendererService();
|
|
51
|
+
}
|
|
52
|
+
this.sceneService = sceneContainer.sceneService;
|
|
53
|
+
this.mapService = sceneContainer.mapService;
|
|
54
|
+
this.iconService = sceneContainer.iconService;
|
|
55
|
+
this.fontService = sceneContainer.fontService;
|
|
56
|
+
this.controlService = sceneContainer.controlService;
|
|
57
|
+
this.layerService = sceneContainer.layerService;
|
|
58
|
+
this.debugService = sceneContainer.debugService;
|
|
59
59
|
this.debugService.setEnable(config.debug);
|
|
60
|
-
this.markerService = sceneContainer.
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
this.interactionService = sceneContainer.get(
|
|
64
|
-
import_l7_core.TYPES.IInteractionService
|
|
65
|
-
);
|
|
66
|
-
this.popupService = sceneContainer.get(import_l7_core.TYPES.IPopupService);
|
|
60
|
+
this.markerService = sceneContainer.markerService;
|
|
61
|
+
this.interactionService = sceneContainer.interactionService;
|
|
62
|
+
this.popupService = sceneContainer.popupService;
|
|
67
63
|
this.boxSelect = new import_boxSelect.default(this, {});
|
|
68
64
|
this.initComponent(id);
|
|
69
65
|
this.sceneService.init(config);
|
|
@@ -126,21 +122,33 @@ var Scene = class {
|
|
|
126
122
|
setBgColor(color) {
|
|
127
123
|
this.mapService.setBgColor(color);
|
|
128
124
|
}
|
|
129
|
-
// layer 管理
|
|
130
125
|
addLayer(layer) {
|
|
126
|
+
if (this.loaded) {
|
|
127
|
+
this.preAddLayer(layer);
|
|
128
|
+
} else {
|
|
129
|
+
this.once("loaded", () => {
|
|
130
|
+
this.preAddLayer(layer);
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
// layer 管理
|
|
135
|
+
preAddLayer(layer) {
|
|
131
136
|
const layerContainer = (0, import_l7_core.createLayerContainer)(this.container);
|
|
132
|
-
layer.setContainer(layerContainer
|
|
137
|
+
layer.setContainer(layerContainer);
|
|
133
138
|
this.sceneService.addLayer(layer);
|
|
134
139
|
if (layer.inited) {
|
|
140
|
+
this.initTileLayer(layer);
|
|
135
141
|
const maskInstance = this.initMask(layer);
|
|
136
142
|
this.addMask(maskInstance, layer.id);
|
|
137
143
|
} else {
|
|
138
144
|
layer.on("inited", () => {
|
|
145
|
+
this.initTileLayer(layer);
|
|
139
146
|
const maskInstance = this.initMask(layer);
|
|
140
147
|
this.addMask(maskInstance, layer.id);
|
|
141
148
|
});
|
|
142
149
|
}
|
|
143
150
|
}
|
|
151
|
+
// 兼容历史接口
|
|
144
152
|
initMask(layer) {
|
|
145
153
|
const {
|
|
146
154
|
mask,
|
|
@@ -164,7 +172,7 @@ var Scene = class {
|
|
|
164
172
|
const parent = this.getLayer(layerId);
|
|
165
173
|
if (parent) {
|
|
166
174
|
const layerContainer = (0, import_l7_core.createLayerContainer)(this.container);
|
|
167
|
-
mask.setContainer(layerContainer
|
|
175
|
+
mask.setContainer(layerContainer);
|
|
168
176
|
parent.addMaskLayer(mask);
|
|
169
177
|
this.sceneService.addMask(mask);
|
|
170
178
|
} else {
|
|
@@ -377,8 +385,8 @@ var Scene = class {
|
|
|
377
385
|
destroy() {
|
|
378
386
|
this.sceneService.destroy();
|
|
379
387
|
}
|
|
380
|
-
registerPostProcessingPass(constructor
|
|
381
|
-
this.container.
|
|
388
|
+
registerPostProcessingPass(constructor) {
|
|
389
|
+
this.container.postProcessingPass.name = new constructor();
|
|
382
390
|
}
|
|
383
391
|
// 控制 shader pick 计算
|
|
384
392
|
enableShaderPick() {
|
|
@@ -434,6 +442,11 @@ var Scene = class {
|
|
|
434
442
|
this.addControl(new import_l7_component.Logo({ position: logoPosition }));
|
|
435
443
|
}
|
|
436
444
|
}
|
|
445
|
+
initTileLayer(layer) {
|
|
446
|
+
if (layer.getSource().isTile) {
|
|
447
|
+
layer.tileLayer = new import_l7_layers.TileLayer(layer);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
437
450
|
};
|
|
438
451
|
// Annotate the CommonJS export names for ESM import in node:
|
|
439
452
|
0 && (module.exports = {
|
package/package.json
CHANGED
|
@@ -1,45 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/l7-scene",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.21.1",
|
|
4
4
|
"description": "",
|
|
5
|
+
"license": "ISC",
|
|
6
|
+
"author": "xiaoiver",
|
|
7
|
+
"sideEffects": false,
|
|
5
8
|
"main": "lib/index.js",
|
|
6
9
|
"module": "es/index.js",
|
|
7
10
|
"types": "es/index.d.ts",
|
|
8
|
-
"sideEffects": false,
|
|
9
11
|
"files": [
|
|
10
12
|
"lib",
|
|
11
13
|
"es",
|
|
12
14
|
"README.md"
|
|
13
15
|
],
|
|
14
16
|
"scripts": {
|
|
15
|
-
"tsc": "tsc --project tsconfig.build.json",
|
|
16
|
-
"clean": "rimraf dist; rimraf es; rimraf lib;",
|
|
17
17
|
"build": "father build",
|
|
18
18
|
"build:cjs": "BABEL_ENV=cjs babel src --root-mode upward --out-dir lib --source-maps --extensions .ts,.tsx --delete-dir-on-start --no-comments",
|
|
19
19
|
"build:esm": "BABEL_ENV=esm babel src --root-mode upward --out-dir es --source-maps --extensions .ts,.tsx --delete-dir-on-start --no-comments",
|
|
20
|
-
"
|
|
21
|
-
"sync": "tnpm sync"
|
|
20
|
+
"clean": "rimraf dist; rimraf es; rimraf lib;",
|
|
21
|
+
"sync": "tnpm sync",
|
|
22
|
+
"tsc": "tsc --project tsconfig.build.json",
|
|
23
|
+
"watch": "BABEL_ENV=cjs babel src --watch --root-mode upward --out-dir lib --source-maps --extensions .ts,.tsx --delete-dir-on-start --no-comments"
|
|
22
24
|
},
|
|
23
|
-
"author": "xiaoiver",
|
|
24
|
-
"license": "ISC",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@antv/l7-component": "2.
|
|
27
|
-
"@antv/l7-core": "2.
|
|
28
|
-
"@antv/l7-layers": "2.
|
|
29
|
-
"@antv/l7-maps": "2.
|
|
30
|
-
"@antv/l7-renderer": "2.
|
|
31
|
-
"@antv/l7-utils": "2.
|
|
26
|
+
"@antv/l7-component": "2.21.1",
|
|
27
|
+
"@antv/l7-core": "2.21.1",
|
|
28
|
+
"@antv/l7-layers": "2.21.1",
|
|
29
|
+
"@antv/l7-maps": "2.21.1",
|
|
30
|
+
"@antv/l7-renderer": "2.21.1",
|
|
31
|
+
"@antv/l7-utils": "2.21.1",
|
|
32
32
|
"@babel/runtime": "^7.7.7",
|
|
33
33
|
"eventemitter3": "^4.0.7",
|
|
34
|
-
"
|
|
35
|
-
"mapbox-gl": "^1.2.1",
|
|
36
|
-
"reflect-metadata": "^0.1.13"
|
|
34
|
+
"mapbox-gl": "^1.2.1"
|
|
37
35
|
},
|
|
38
36
|
"devDependencies": {
|
|
39
|
-
"@antv/l7-test-utils": "2.
|
|
37
|
+
"@antv/l7-test-utils": "2.21.1"
|
|
40
38
|
},
|
|
41
|
-
"gitHead": "1966dbadf9efee8d69d22beb4d89947c158da634",
|
|
42
39
|
"publishConfig": {
|
|
43
40
|
"access": "public"
|
|
44
|
-
}
|
|
41
|
+
},
|
|
42
|
+
"gitHead": "1e0d2e5920f479f77095a2c5eddda8a8d7ac9e0f"
|
|
45
43
|
}
|