@antv/l7-scene 2.20.19 → 2.21.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/es/index.d.ts +5 -4
- package/es/index.js +57 -28
- package/lib/index.js +39 -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,46 @@ 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
|
+
console.log('layer not loaded');
|
|
191
|
+
this.once('loaded', function () {
|
|
192
|
+
console.log('layer loaded');
|
|
193
|
+
_this2.preAddLayer(layer);
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// layer 管理
|
|
199
|
+
}, {
|
|
200
|
+
key: "preAddLayer",
|
|
201
|
+
value: function preAddLayer(layer) {
|
|
202
|
+
var _this3 = this;
|
|
185
203
|
// 为当前图层创建一个容器
|
|
186
204
|
// TODO: 初始化的时候设置 容器
|
|
187
205
|
var layerContainer = createLayerContainer(this.container);
|
|
188
|
-
layer.setContainer(layerContainer
|
|
206
|
+
layer.setContainer(layerContainer);
|
|
189
207
|
this.sceneService.addLayer(layer);
|
|
190
208
|
|
|
191
209
|
// mask 在 scene loaded 之后执行
|
|
192
210
|
if (layer.inited) {
|
|
211
|
+
this.initTileLayer(layer);
|
|
193
212
|
var maskInstance = this.initMask(layer);
|
|
194
213
|
this.addMask(maskInstance, layer.id);
|
|
195
214
|
} else {
|
|
196
215
|
layer.on('inited', function () {
|
|
197
|
-
|
|
198
|
-
|
|
216
|
+
_this3.initTileLayer(layer);
|
|
217
|
+
var maskInstance = _this3.initMask(layer); // 初始化 mask
|
|
218
|
+
_this3.addMask(maskInstance, layer.id);
|
|
199
219
|
});
|
|
200
220
|
}
|
|
201
221
|
}
|
|
222
|
+
// 兼容历史接口
|
|
202
223
|
}, {
|
|
203
224
|
key: "initMask",
|
|
204
225
|
value: function initMask(layer) {
|
|
@@ -227,7 +248,7 @@ var Scene = /*#__PURE__*/function () {
|
|
|
227
248
|
var parent = this.getLayer(layerId);
|
|
228
249
|
if (parent) {
|
|
229
250
|
var layerContainer = createLayerContainer(this.container);
|
|
230
|
-
mask.setContainer(layerContainer
|
|
251
|
+
mask.setContainer(layerContainer);
|
|
231
252
|
parent.addMaskLayer(mask);
|
|
232
253
|
this.sceneService.addMask(mask);
|
|
233
254
|
} else {
|
|
@@ -319,12 +340,12 @@ var Scene = /*#__PURE__*/function () {
|
|
|
319
340
|
}, {
|
|
320
341
|
key: "addIconFonts",
|
|
321
342
|
value: function addIconFonts(options) {
|
|
322
|
-
var
|
|
343
|
+
var _this4 = this;
|
|
323
344
|
options.forEach(function (_ref) {
|
|
324
345
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
325
346
|
name = _ref2[0],
|
|
326
347
|
fontUnicode = _ref2[1];
|
|
327
|
-
|
|
348
|
+
_this4.fontService.addIconFont(name, fontUnicode);
|
|
328
349
|
});
|
|
329
350
|
}
|
|
330
351
|
/**
|
|
@@ -335,9 +356,9 @@ var Scene = /*#__PURE__*/function () {
|
|
|
335
356
|
}, {
|
|
336
357
|
key: "addFontFace",
|
|
337
358
|
value: function addFontFace(fontFamily, fontPath) {
|
|
338
|
-
var
|
|
359
|
+
var _this5 = this;
|
|
339
360
|
this.fontService.once('fontloaded', function (e) {
|
|
340
|
-
|
|
361
|
+
_this5.emit('fontloaded', e);
|
|
341
362
|
});
|
|
342
363
|
this.fontService.addFontFace(fontFamily, fontPath);
|
|
343
364
|
}
|
|
@@ -601,8 +622,8 @@ var Scene = /*#__PURE__*/function () {
|
|
|
601
622
|
}
|
|
602
623
|
}, {
|
|
603
624
|
key: "registerPostProcessingPass",
|
|
604
|
-
value: function registerPostProcessingPass(constructor
|
|
605
|
-
this.container.
|
|
625
|
+
value: function registerPostProcessingPass(constructor) {
|
|
626
|
+
this.container.postProcessingPass.name = new constructor();
|
|
606
627
|
}
|
|
607
628
|
|
|
608
629
|
// 控制 shader pick 计算
|
|
@@ -619,12 +640,12 @@ var Scene = /*#__PURE__*/function () {
|
|
|
619
640
|
}, {
|
|
620
641
|
key: "enableBoxSelect",
|
|
621
642
|
value: function enableBoxSelect() {
|
|
622
|
-
var
|
|
643
|
+
var _this6 = this;
|
|
623
644
|
var once = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
624
645
|
this.boxSelect.enable();
|
|
625
646
|
if (once) {
|
|
626
647
|
this.boxSelect.once('selectend', function () {
|
|
627
|
-
|
|
648
|
+
_this6.disableBoxSelect();
|
|
628
649
|
});
|
|
629
650
|
}
|
|
630
651
|
}
|
|
@@ -678,6 +699,14 @@ var Scene = /*#__PURE__*/function () {
|
|
|
678
699
|
}));
|
|
679
700
|
}
|
|
680
701
|
}
|
|
702
|
+
}, {
|
|
703
|
+
key: "initTileLayer",
|
|
704
|
+
value: function initTileLayer(layer) {
|
|
705
|
+
if (layer.getSource().isTile) {
|
|
706
|
+
layer.tileLayer = new TileLayer(layer);
|
|
707
|
+
// Todo 支持瓦片更新
|
|
708
|
+
}
|
|
709
|
+
}
|
|
681
710
|
}], [{
|
|
682
711
|
key: "addProtocol",
|
|
683
712
|
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,35 @@ 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
|
+
console.log("layer not loaded");
|
|
130
|
+
this.once("loaded", () => {
|
|
131
|
+
console.log("layer loaded");
|
|
132
|
+
this.preAddLayer(layer);
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
// layer 管理
|
|
137
|
+
preAddLayer(layer) {
|
|
131
138
|
const layerContainer = (0, import_l7_core.createLayerContainer)(this.container);
|
|
132
|
-
layer.setContainer(layerContainer
|
|
139
|
+
layer.setContainer(layerContainer);
|
|
133
140
|
this.sceneService.addLayer(layer);
|
|
134
141
|
if (layer.inited) {
|
|
142
|
+
this.initTileLayer(layer);
|
|
135
143
|
const maskInstance = this.initMask(layer);
|
|
136
144
|
this.addMask(maskInstance, layer.id);
|
|
137
145
|
} else {
|
|
138
146
|
layer.on("inited", () => {
|
|
147
|
+
this.initTileLayer(layer);
|
|
139
148
|
const maskInstance = this.initMask(layer);
|
|
140
149
|
this.addMask(maskInstance, layer.id);
|
|
141
150
|
});
|
|
142
151
|
}
|
|
143
152
|
}
|
|
153
|
+
// 兼容历史接口
|
|
144
154
|
initMask(layer) {
|
|
145
155
|
const {
|
|
146
156
|
mask,
|
|
@@ -164,7 +174,7 @@ var Scene = class {
|
|
|
164
174
|
const parent = this.getLayer(layerId);
|
|
165
175
|
if (parent) {
|
|
166
176
|
const layerContainer = (0, import_l7_core.createLayerContainer)(this.container);
|
|
167
|
-
mask.setContainer(layerContainer
|
|
177
|
+
mask.setContainer(layerContainer);
|
|
168
178
|
parent.addMaskLayer(mask);
|
|
169
179
|
this.sceneService.addMask(mask);
|
|
170
180
|
} else {
|
|
@@ -377,8 +387,8 @@ var Scene = class {
|
|
|
377
387
|
destroy() {
|
|
378
388
|
this.sceneService.destroy();
|
|
379
389
|
}
|
|
380
|
-
registerPostProcessingPass(constructor
|
|
381
|
-
this.container.
|
|
390
|
+
registerPostProcessingPass(constructor) {
|
|
391
|
+
this.container.postProcessingPass.name = new constructor();
|
|
382
392
|
}
|
|
383
393
|
// 控制 shader pick 计算
|
|
384
394
|
enableShaderPick() {
|
|
@@ -434,6 +444,11 @@ var Scene = class {
|
|
|
434
444
|
this.addControl(new import_l7_component.Logo({ position: logoPosition }));
|
|
435
445
|
}
|
|
436
446
|
}
|
|
447
|
+
initTileLayer(layer) {
|
|
448
|
+
if (layer.getSource().isTile) {
|
|
449
|
+
layer.tileLayer = new import_l7_layers.TileLayer(layer);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
437
452
|
};
|
|
438
453
|
// Annotate the CommonJS export names for ESM import in node:
|
|
439
454
|
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.0",
|
|
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.0",
|
|
27
|
+
"@antv/l7-core": "2.21.0",
|
|
28
|
+
"@antv/l7-layers": "2.21.0",
|
|
29
|
+
"@antv/l7-maps": "2.21.0",
|
|
30
|
+
"@antv/l7-renderer": "2.21.0",
|
|
31
|
+
"@antv/l7-utils": "2.21.0",
|
|
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.0"
|
|
40
38
|
},
|
|
41
|
-
"gitHead": "7a7fb59e506d8d970d296fa6efc7e668513a25f6",
|
|
42
39
|
"publishConfig": {
|
|
43
40
|
"access": "public"
|
|
44
|
-
}
|
|
41
|
+
},
|
|
42
|
+
"gitHead": "7fa1b00b5262c98bb4cceef4eaf87a7b10af7e29"
|
|
45
43
|
}
|