Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shihui dev #819

Merged
merged 199 commits into from
Nov 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
199 commits
Select commit Hold shift + click to select a range
0b23a0a
feat: 增加小程序环境判断、替换 regl -> l7regl
yiiiiiiqianyao Aug 11, 2021
de81196
style: code style
yiiiiiiqianyao Aug 11, 2021
077b1fc
feat(新增工程配置): 新增小程序工程配置
StuRuby Aug 11, 2021
291454d
Merge branch 'feat_l7_map_mini' of https://github.com/antvis/L7 into …
StuRuby Aug 11, 2021
c75044a
feat: 支持小程序环境中传入 canvas 实例用于渲染、兼容 L7 原有代码
yiiiiiiqianyao Aug 11, 2021
07c3824
style: code style
yiiiiiiqianyao Aug 11, 2021
06a1b1f
feat: 小程序不需要对 classList 操作(真机也没有 classList 属性)
yiiiiiiqianyao Aug 11, 2021
2bfa8a0
style: code style
yiiiiiiqianyao Aug 11, 2021
b2b8703
feat: 对 docStyle、devicePixelRatio 以及部分 dom 的兼容
yiiiiiiqianyao Aug 11, 2021
6bd8475
style: code style
yiiiiiiqianyao Aug 11, 2021
7a8924a
feat: 小程序兼容 window.perframce.now requestAnimationFrame
yiiiiiiqianyao Aug 11, 2021
f8ee423
feat: 新增工程配置
StuRuby Aug 11, 2021
6dc3bd8
feat: 新增工程配置
StuRuby Aug 11, 2021
8a13203
feat: 兼容动画减弱以及部分的 dom 处理
yiiiiiiqianyao Aug 12, 2021
ba8ffe7
style: code style
yiiiiiiqianyao Aug 12, 2021
3720f02
feat: 替换 mapbox/tiny-sdf -> l7-tiny-sdf
yiiiiiiqianyao Aug 13, 2021
919508b
style: code style
yiiiiiiqianyao Aug 13, 2021
496d928
feat: 兼容操作
yiiiiiiqianyao Aug 13, 2021
b7651f8
style: code style
yiiiiiiqianyao Aug 13, 2021
f82ac51
style: demo code
yiiiiiiqianyao Aug 15, 2021
c66bcf7
feat: change version
yiiiiiiqianyao Aug 15, 2021
7e74daa
feat: mini code
yiiiiiiqianyao Aug 16, 2021
db095ed
feat: 小程序兼容
yiiiiiiqianyao Aug 16, 2021
55e7886
Merge branch 'feat_l7_map_mini' of https://github.com/antvis/L7 into …
StuRuby Aug 16, 2021
ed4834d
feat: 合并mini-adapter
StuRuby Aug 16, 2021
d5ca439
feat: 合并mini-adapter
StuRuby Aug 16, 2021
8956ce8
feat: 新增tag
StuRuby Aug 17, 2021
3694bad
feat: 增加 imageData 兼容
yiiiiiiqianyao Aug 17, 2021
acebed8
style: code style by lint
yiiiiiiqianyao Aug 17, 2021
39747ac
feat: 修改版本号
StuRuby Aug 17, 2021
53c92b4
Merge branch 'feat_l7_map_mini' of https://github.com/antvis/L7 into …
yiiiiiiqianyao Aug 17, 2021
4959e63
feat: 新增mini6 beta版本
StuRuby Aug 17, 2021
5792111
feat: 去除原adapter
StuRuby Aug 17, 2021
597314a
feat: 修改版本号
StuRuby Aug 17, 2021
79e1e9e
feat: 升级版本
StuRuby Aug 18, 2021
51b2ee5
feat: 修改版本引用
StuRuby Aug 18, 2021
a15e5c0
style: code style
yiiiiiiqianyao Aug 19, 2021
10dcf42
feat: 小程序兼容requestAnimationFrame
StuRuby Aug 19, 2021
7e097cf
feat: 小程序兼容requestAnimationFrame
StuRuby Aug 19, 2021
03f94e7
Merge branch 'feat_l7_map_mini' of https://github.com/antvis/L7 into …
yiiiiiiqianyao Aug 23, 2021
a168b5f
style: maps -> mini
yiiiiiiqianyao Aug 23, 2021
e146625
feat: update mini version
yiiiiiiqianyao Aug 23, 2021
86edce9
feat: 修改 webgl 扩展名称的大小写、使之可以与 l7regl 配合,兼容小程序环境
yiiiiiiqianyao Aug 24, 2021
ad7ce0e
feat: 用适配的 requestAnimateFrame 替换 setInterval
yiiiiiiqianyao Aug 26, 2021
be3e40b
feat: 修改 L7 - mini 版本、修改 adapter 中 screen、devicePixelRadio 关于 isMini 的取值
yiiiiiiqianyao Aug 26, 2021
f3bf89b
feat: 修复小程序环境中 getMapTouches 的取值
yiiiiiiqianyao Aug 26, 2021
94eff52
feat: 地图联动部分改造
yiiiiiiqianyao Aug 31, 2021
83a9359
feat: 增加地图联动
yiiiiiiqianyao Sep 1, 2021
adad88d
feat: 修复新增小程序地图联动
yiiiiiiqianyao Sep 1, 2021
785913b
feat: 增加小程序地图联动
yiiiiiiqianyao Sep 2, 2021
f6553b1
style: lint style
yiiiiiiqianyao Sep 2, 2021
a3c8cd5
Merge branch 'feat_l7_map_mini' of https://github.com/antvis/L7 into …
yiiiiiiqianyao Sep 2, 2021
e1828cf
style: handle merge conflict
yiiiiiiqianyao Sep 2, 2021
7e2741d
feat: 增加有无底图模式的参数控制、修复与小程序地图联动时的 bug
yiiiiiiqianyao Sep 2, 2021
5d21f91
style: lint style
yiiiiiiqianyao Sep 2, 2021
44320b9
feat: 扩展小程序地图联动传递参数
yiiiiiiqianyao Sep 7, 2021
d343c6d
style: lint style
yiiiiiiqianyao Sep 7, 2021
724baf6
chore: update L7Mini version 2.5.8 - mini16 -> 2.5.8 - mini17
yiiiiiiqianyao Sep 7, 2021
35b0903
feat: 增加小程序可视化交互注册监听时上下文绑定
yiiiiiiqianyao Sep 8, 2021
230f1bf
style: lint style
yiiiiiiqianyao Sep 8, 2021
4c4583d
chore: update L7Mini version 2.5.8mini17 -> 2.5.8mini18
yiiiiiiqianyao Sep 10, 2021
7a9a889
chore: update L7Mini version 2.5.8mini18 -> 2.5.8mini19
yiiiiiiqianyao Sep 10, 2021
bde5c7b
chore: update L7Mini version 2.5.8mini20 -> 2.5.8mini21
yiiiiiiqianyao Sep 10, 2021
d072451
feat: add performance demo
yiiiiiiqianyao Sep 15, 2021
15b0b8f
style: lint style
yiiiiiiqianyao Sep 15, 2021
bc8737d
Merge branch 'shihui_dev' into shihui_performance
yiiiiiiqianyao Sep 15, 2021
2bd82c0
style: lint style
yiiiiiiqianyao Sep 15, 2021
f8f2250
Merge branch 'master' into shihui_performance
yiiiiiiqianyao Sep 17, 2021
5325df4
feat: add getModelMatrix into viewport
yiiiiiiqianyao Sep 24, 2021
9d4fb34
feat: 新增地球模式 (初步构建)
yiiiiiiqianyao Sep 24, 2021
fb71f1e
feat: 完善地球交互
yiiiiiiqianyao Sep 24, 2021
2f6b671
style: lint style
yiiiiiiqianyao Sep 24, 2021
d369b31
feat: 调整地球图层缩放的方向
yiiiiiiqianyao Sep 24, 2021
26cc7f6
style: lint style
yiiiiiiqianyao Sep 24, 2021
7dd16aa
feat: 增加地球模式的 pointLayer/fill 图层
yiiiiiiqianyao Sep 26, 2021
fffb556
style: lint style
yiiiiiiqianyao Sep 26, 2021
7784f76
feat: 增加地球、太阳的简单运动系统,优化部分代码结构
yiiiiiiqianyao Sep 27, 2021
7c958f5
Merge branch 'master' into shihui_dev
yiiiiiiqianyao Sep 27, 2021
70804e2
fix: 修复时间点击出错
yiiiiiiqianyao Sep 28, 2021
dfc0656
style: lint style
yiiiiiiqianyao Sep 28, 2021
d65749f
Merge branch 'master' into shihui_dev
yiiiiiiqianyao Sep 29, 2021
86f2422
fix: 修复地图 panBy 方法参数错误
yiiiiiiqianyao Oct 8, 2021
3a31170
style: lint style
yiiiiiiqianyao Oct 8, 2021
0edae80
Merge branch 'master' into shihui_model
yiiiiiiqianyao Oct 8, 2021
f06b07c
Merge branch 'master' into shihui_dev
yiiiiiiqianyao Oct 8, 2021
a3a511c
Merge branch 'master' into earth
yiiiiiiqianyao Oct 8, 2021
19c1172
Merge branch 'master' into shihui_model
yiiiiiiqianyao Oct 8, 2021
e9a022d
feat: pointLayer/cylinder 圆柱兼容地球模式
yiiiiiiqianyao Oct 9, 2021
d67b125
style: lint style
yiiiiiiqianyao Oct 9, 2021
34c8785
Merge branch 'earth' into shihui_dev
yiiiiiiqianyao Oct 9, 2021
533be57
Merge branch 'master' into shihui_dev
yiiiiiiqianyao Oct 9, 2021
a4cc063
Merge branch 'master' into earth
yiiiiiiqianyao Oct 9, 2021
a928e2f
Merge branch 'master' into shihui_model
yiiiiiiqianyao Oct 9, 2021
d4a059c
feat: 修复 pointLayer/fill 在拾取是破面严重的情况
yiiiiiiqianyao Oct 9, 2021
a938b71
style: lint style
yiiiiiiqianyao Oct 9, 2021
435493c
feat: 增加 arc 弧度调节
yiiiiiiqianyao Oct 9, 2021
a4989e2
Merge branch 'earth' into shihui_dev
yiiiiiiqianyao Oct 9, 2021
13e9a2a
Merge branch 'master' into shihui_dev
yiiiiiiqianyao Oct 9, 2021
f4f682d
Merge branch 'master' into earth
yiiiiiiqianyao Oct 9, 2021
e8896ae
Merge branch 'master' into shihui_model
yiiiiiiqianyao Oct 9, 2021
f5588a0
feat: 增加 lineLayer/arc3d 兼容地球模式
yiiiiiiqianyao Oct 11, 2021
74478ab
style: lint style
yiiiiiiqianyao Oct 11, 2021
c13def1
Merge branch 'earth' into shihui_dev
yiiiiiiqianyao Oct 11, 2021
581baa4
Merge branch 'master' into shihui_dev
yiiiiiiqianyao Oct 11, 2021
2b4e2b2
Merge branch 'master' into earth
yiiiiiiqianyao Oct 11, 2021
48cc803
feat: 增加地球图层 - 大气层
yiiiiiiqianyao Oct 11, 2021
9adada7
style: lint style
yiiiiiiqianyao Oct 11, 2021
1b2451e
feat: 增加设置可视化层背景色的能力
yiiiiiiqianyao Oct 11, 2021
6726599
style: lint style
yiiiiiiqianyao Oct 11, 2021
9a7f390
Merge branch 'earth' into shihui_dev
yiiiiiiqianyao Oct 11, 2021
b4aa54a
Merge branch 'master' into shihui_dev
yiiiiiiqianyao Oct 12, 2021
0493bc8
feat: 增加地球外发光效果
yiiiiiiqianyao Oct 12, 2021
3aa119a
style: lint style
yiiiiiiqianyao Oct 12, 2021
5d6c49c
feat: 允许用户不使用 layer 的 source 方法 - 地球模式下光晕图层不需要传数据
yiiiiiiqianyao Oct 12, 2021
4f3b470
style: lint style
yiiiiiiqianyao Oct 12, 2021
1d456aa
feat: 调整光晕的 shader 计算
yiiiiiiqianyao Oct 12, 2021
4c785bf
Merge branch 'master' into shihui_dev
yiiiiiiqianyao Oct 12, 2021
d3e8105
feat: 调整地球大气层的渲染层级
yiiiiiiqianyao Oct 12, 2021
56c37f6
style: lint style
yiiiiiiqianyao Oct 12, 2021
74d684b
feat: 调整案例
yiiiiiiqianyao Oct 12, 2021
8f9e44e
style: lint style
yiiiiiiqianyao Oct 12, 2021
f047e81
Merge branch 'master' into shihui_dev
yiiiiiiqianyao Oct 12, 2021
fd1ccce
feat: 增加地球图层的默认参数、调整部分代码
yiiiiiiqianyao Oct 13, 2021
936b340
style: lint style
yiiiiiiqianyao Oct 13, 2021
3c61981
Merge branch 'master' into shihui_dev
yiiiiiiqianyao Oct 13, 2021
0ae0805
Merge branch 'master' into shihui_dev
yiiiiiiqianyao Oct 14, 2021
39b36b5
feat: imageTile developinging
yiiiiiiqianyao Oct 14, 2021
f5803e9
style: lint style
yiiiiiiqianyao Oct 14, 2021
7a97f14
feat: 新增图片瓦片地图
yiiiiiiqianyao Oct 19, 2021
77fbe17
fix: 修复 amap2 新增样式导致的 marker 失效
yiiiiiiqianyao Oct 19, 2021
86dfc34
feat: 修复 amap2 的 amap-maps 新增 z-index=0; 引发的marker 显示层级失效
yiiiiiiqianyao Oct 19, 2021
850990d
feat: amap2 的 amap-maps 新增 z-index=0; 样式,让 marker 中 zIndex 失效
yiiiiiiqianyao Oct 19, 2021
d4a5a88
style: lint style
yiiiiiiqianyao Oct 19, 2021
1ca73b2
Merge branch 'master' into shihui_dev
yiiiiiiqianyao Oct 20, 2021
edc3582
Merge branch 'master' into shihui_tile
yiiiiiiqianyao Oct 20, 2021
e5b5b87
feat: 补全瓦片地图中的类型引用
yiiiiiiqianyao Oct 20, 2021
1b2db4f
style: lint style
yiiiiiiqianyao Oct 20, 2021
a8c0f52
Merge branch 'official_mini' into merge_mini
yiiiiiiqianyao Oct 20, 2021
dae6cb6
feat: 取消 earthmap 的 hash 模块
yiiiiiiqianyao Oct 20, 2021
80815a6
feat: 调整 L7Mini 版本
yiiiiiiqianyao Oct 20, 2021
b8e2337
Merge branch 'shihui_tile' into merge_mini
yiiiiiiqianyao Oct 20, 2021
cacaaa2
feat: 合并图片瓦片图层
yiiiiiiqianyao Oct 20, 2021
e4ed2ad
feat: 增加 imageLayer 的对小程序的兼容
yiiiiiiqianyao Oct 20, 2021
54f2a99
style: lint style
yiiiiiiqianyao Oct 20, 2021
0a8547a
feat: 修改小程序分支版本
yiiiiiiqianyao Oct 20, 2021
1cfde9a
feat: 更新 l7regl 依赖(补充对支付宝小程序 image 对象的类型判断)
yiiiiiiqianyao Oct 21, 2021
c1445eb
Merge branch 'master' into shihui_model
yiiiiiiqianyao Oct 21, 2021
e99d93a
feat: 增加 demo
yiiiiiiqianyao Oct 22, 2021
001997c
style: lint style
yiiiiiiqianyao Oct 22, 2021
bd49695
feat: 修复 varying 传递 float 总数在部分终端设备 ios13 上突破限制的问题
yiiiiiiqianyao Oct 22, 2021
7b4ad2d
Merge branch 'master' into shihui_dev
yiiiiiiqianyao Oct 22, 2021
8db7821
Merge branch 'master' into shihui_model
yiiiiiiqianyao Oct 22, 2021
ecfc7c7
feat: add stoty demo
yiiiiiiqianyao Oct 25, 2021
af8c7f0
style: lint style
yiiiiiiqianyao Oct 25, 2021
61f12e3
feat: 调整 aspace demo
yiiiiiiqianyao Oct 25, 2021
ea49ac3
Merge branch 'shihui_model' into shihui_dev
yiiiiiiqianyao Oct 25, 2021
827702f
Merge branch 'shihui_tile' into shihui_dev
yiiiiiiqianyao Oct 25, 2021
a2856fe
feat: 调整 aspace demo
yiiiiiiqianyao Oct 25, 2021
17469ca
style: lint style
yiiiiiiqianyao Oct 25, 2021
ef01994
feat: 调整 demo
yiiiiiiqianyao Oct 25, 2021
939e916
feat: 补充依赖
yiiiiiiqianyao Oct 25, 2021
eb9d7ef
Merge branch 'master' into shihui_dev
yiiiiiiqianyao Oct 26, 2021
397da9c
Merge branch 'master' into shihui_performance
yiiiiiiqianyao Oct 26, 2021
8468683
feat: 新增 arcmini layer,增加拖拽时的拾取优化(地图拖拽时取消拾取)
yiiiiiiqianyao Oct 26, 2021
7068273
Merge branch 'shihui_performance' into shihui_dev
yiiiiiiqianyao Oct 26, 2021
0ace3fe
feat: 增加注释
yiiiiiiqianyao Oct 26, 2021
9790a3a
Merge branch 'master' into shihui_dev
yiiiiiiqianyao Oct 26, 2021
3beeafa
Merge branch 'master' into shihui_performance
yiiiiiiqianyao Oct 26, 2021
6b70f97
feat: 剔除地图拖拽时多余的 shader 计算
yiiiiiiqianyao Oct 27, 2021
f1b4e4b
style: lint style
yiiiiiiqianyao Oct 27, 2021
390f194
Merge branch 'shihui_performance' into shihui_dev
yiiiiiiqianyao Oct 27, 2021
d897a1a
feat: 暂时取消拖拽时 shader 的过滤处理
yiiiiiiqianyao Oct 28, 2021
b2766b7
Merge branch 'merge_mini' of https://github.com/antvis/L7 into merge_…
yiiiiiiqianyao Oct 28, 2021
0ecb2b1
style: lint style
yiiiiiiqianyao Oct 28, 2021
811ae21
feat: 合并 mi nimini
yiiiiiiqianyao Oct 28, 2021
50faae6
feat: add l7hammerjs
yiiiiiiqianyao Oct 28, 2021
7fb879e
feat: 增加 l7hammerjs 声明
yiiiiiiqianyao Oct 28, 2021
582bea4
feat: update version
yiiiiiiqianyao Oct 28, 2021
f2d3eb5
Merge branch 'shihui_dev' into mergemaster
yiiiiiiqianyao Oct 29, 2021
ae85d70
feat: merge shihui_dev
yiiiiiiqianyao Oct 29, 2021
b846ac4
feat: 去除多余依赖
yiiiiiiqianyao Oct 29, 2021
7eae4c4
Merge branch 'mergemaster' into shihui_mergemini
yiiiiiiqianyao Oct 29, 2021
b34d1af
feat: 小程序合并 master 无报错版本
yiiiiiiqianyao Oct 29, 2021
b0179e3
feat: 修改 demo
yiiiiiiqianyao Oct 29, 2021
1224fa2
style: lint style
yiiiiiiqianyao Oct 29, 2021
b0192f7
feat: change l7hammerjs
yiiiiiiqianyao Oct 29, 2021
8c62feb
feat: remove test hammerjs
yiiiiiiqianyao Oct 29, 2021
6629a01
chore: update verison and get enable branch 2.5.37-mini19
yiiiiiiqianyao Nov 1, 2021
454097b
Merge branch 'shihui_mergemini' into mergemini19
yiiiiiiqianyao Nov 1, 2021
a2f131e
chore: update version 2.5.37-mini19 -> 2.5.37-mini20 enabled
yiiiiiiqianyao Nov 1, 2021
7a75db5
feat: 去除 hammerjs 的类型定义 - l7hammerjs
yiiiiiiqianyao Nov 1, 2021
3f90be5
style: lint style
yiiiiiiqianyao Nov 1, 2021
c69cb5d
feat: 增加类型定义 @antv/l7-maps/lib/map/
yiiiiiiqianyao Nov 1, 2021
3444c0a
feat: 调整类型定义
yiiiiiiqianyao Nov 1, 2021
06a174b
feat: 调整类型定义文件
yiiiiiiqianyao Nov 1, 2021
28c758a
feat: change typing
yiiiiiiqianyao Nov 1, 2021
50ecd0f
Merge branch 'master' into shihui_dev
yiiiiiiqianyao Nov 2, 2021
016e384
feat: 增加图层渲染列表 layerList 更新图层渲染排序计算 去除夺取 renderTest
yiiiiiiqianyao Nov 2, 2021
13eba7e
style: lint style
yiiiiiiqianyao Nov 2, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions build/rollup-plugin-miniapp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import inject from '@rollup/plugin-inject';
import modify from '@rollup/plugin-modify';

const module = '@oasis-engine/miniprogram-adapter ';

function register(name) {
return [module, name];
}

function resolveFile(filePath) {
return path.join(__dirname, '..', filePath);
}

const adapterArray = [
'window',
'atob',
'devicePixelRatio',
'document',
'Element',
'Event',
'EventTarget',
'HTMLCanvasElement',
'HTMLElement',
'HTMLMediaElement',
'HTMLVideoElement',
'Image',
'navigator',
'Node',
'requestAnimationFrame',
'cancelAnimationFrame',
'screen',
'XMLHttpRequest',
'performance',
];
const adapterVars = {};

adapterArray.forEach((name) => {
adapterVars[name] = register(name);
});

export default [
inject(adapterVars),
modify({
find: /^@antv\/l7-(.*)/,
replacement: resolveFile('packages/$1/src'),
}),
];
3 changes: 1 addition & 2 deletions packages/core/src/services/interaction/PickingService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,7 @@ export default class PickingService implements IPickingService {
}
this.alreadyInPicking = true;
await this.pickingLayers(target);
// TODO: 触发图层更新渲染,同时传递更新类型
this.layerService.renderLayers('picking');
this.layerService.renderLayers();
this.alreadyInPicking = false;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/services/layer/ILayerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ export interface ILayerService {
getLayerByName(name: string): ILayer | undefined;
remove(layer: ILayer, parentLayer?: ILayer): void;
removeAllLayers(): void;
updateRenderOrder(): void;
updateLayerRenderList(): void;
renderLayers(type?: string): void;
getOESTextureFloat(): boolean;
isMapDragging(): boolean;
Expand Down
111 changes: 29 additions & 82 deletions packages/core/src/services/layer/LayerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,14 @@ export default class LayerService implements ILayerService {

private layers: ILayer[] = [];

private layerList: ILayer[] = [];

private layerRenderID: number;

private sceneInited: boolean = false;

private animateInstanceCount: number = 0;

private lastRenderType: string;

private lastPickRenderTime: number;

@inject(TYPES.IRendererService)
private readonly renderService: IRendererService;

Expand All @@ -41,6 +39,7 @@ export default class LayerService implements ILayerService {
layer.init();
}
this.layers.push(layer);
this.updateLayerRenderList();
}

public initLayers() {
Expand All @@ -50,6 +49,7 @@ export default class LayerService implements ILayerService {
layer.init();
}
});
this.updateLayerRenderList();
}

public getLayers(): ILayer[] {
Expand Down Expand Up @@ -77,7 +77,7 @@ export default class LayerService implements ILayerService {
this.layers.splice(layerIndex, 1);
}
}

this.updateLayerRenderList();
layer.emit('remove', null);
layer.destroy();
this.renderLayers();
Expand All @@ -87,46 +87,42 @@ export default class LayerService implements ILayerService {
this.destroy();
}

public renderLayers(renderType?: string) {
// TODO: 每次渲染的时候都需要进行渲染判断,判断是否进行渲染
// 没有传递 type 参数时默认触发的是地图事件,优先级最高,直接渲染
if (!this.renderTest(renderType)) {
return;
}

public renderLayers() {
if (this.alreadyInRendering) {
return;
}
this.alreadyInRendering = true;
this.clear();
this.updateRenderOrder();

this.layerList.forEach((layer) => {
layer.hooks.beforeRenderData.call();
layer.hooks.beforeRender.call();
layer.render();
layer.hooks.afterRender.call();
});
this.alreadyInRendering = false;
}

public updateLayerRenderList() {
// TODO: 每次更新都是从 layers 重新构建
this.layerList = [];
this.layers
.filter((layer) => layer.inited)
.filter((layer) => layer.isVisible())
.forEach((layer) => {
this.layerList.push(layer);

// Tip: 渲染 layer 的子图层 默认 layerChildren 为空数组 表示没有子图层 目前只有 ImageTileLayer 有子图层
renderLayerEvent(layer.layerChildren);
renderLayerEvent([layer]);
layer.layerChildren
.filter((childlayer) => childlayer.inited)
.filter((childlayer) => childlayer.isVisible())
.forEach((childlayer) => {
this.layerList.push(childlayer);
});
});
this.alreadyInRendering = false;

function renderLayerEvent(layers: ILayer[]) {
layers
.filter((layer) => layer.inited)
.filter((layer) => layer.isVisible())
.forEach((layer) => {
// trigger hooks
layer.hooks.beforeRenderData.call();
layer.hooks.beforeRender.call();
layer.render();
layer.hooks.afterRender.call();
});
}
}

public updateRenderOrder() {
this.layers.sort((pre: ILayer, next: ILayer) => {
// 根据 zIndex 对渲染顺序进行排序
this.layerList.sort((pre: ILayer, next: ILayer) => {
return pre.zIndex - next.zIndex;
});
}
Expand All @@ -141,6 +137,7 @@ export default class LayerService implements ILayerService {
layer.destroy();
});
this.layers = [];
this.layerList = [];
this.renderLayers();
}

Expand Down Expand Up @@ -172,56 +169,6 @@ export default class LayerService implements ILayerService {
this.layerRenderID = requestAnimationFrame(this.runRender.bind(this));
}

// 渲染检测
private renderTest(renderType: string | undefined): boolean {
const now = new Date().getTime();
const betweenPickRenderTime = now - this.lastPickRenderTime;
if (renderType === 'picking') {
this.lastPickRenderTime = new Date().getTime();
}

// 继续渲染事件
if (renderType) {
switch (renderType) {
case 'picking':
// return false;
// TODO: picking 类型的渲染事件
// 若是上次触发为地图触发的渲染,则认为是地图事件与拾取事件在同时触发,放弃此次渲染
if (
this.lastRenderType === 'mapRender' ||
this.lastRenderType === 'animate'
) {
this.lastRenderType = 'picking';
// 如果上一次触发的事件在 48 ms 以上,则这一次不放弃触发
if (betweenPickRenderTime > 48) {
return true;
} else {
return false;
}
} else {
this.lastRenderType = 'picking';
return true;
}
case 'animate':
// return false;
if (this.lastRenderType === 'mapRender') {
this.lastRenderType = 'animate';
return false;
} else {
this.lastRenderType = 'animate';
return true;
}
case 'mapRender':
this.lastRenderType = 'mapRender';
return true;
default:
return true;
}
// TODO: 地图触发的渲染优先级最高,动画其次,拾取最次
}
return true;
}

private clear() {
const color = rgb2arr(this.mapService.bgColor) as [
number,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/services/scene/ISceneService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface ISceneService {
initMiniScene(config: IMapConfig & IRenderConfig): void;
addLayer(layer: ILayer): void;
getSceneConfig(): Partial<ISceneConfig>;
render(type?: string): void;
render(): void;
getSceneContainer(): HTMLDivElement;
getMarkerContainer(): HTMLElement;
exportPng(type?: 'png' | 'jpg'): string;
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/services/scene/SceneService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ export default class Scene extends EventEmitter implements ISceneService {
this.render();
}

public async render(renderType?: string) {
public async render() {
if (this.rendering || this.destroyed) {
return;
}
Expand All @@ -325,7 +325,7 @@ export default class Scene extends EventEmitter implements ISceneService {
}

// 尝试初始化未初始化的图层
this.layerService.renderLayers(renderType);
this.layerService.renderLayers();

// 组件需要等待layer 初始化完成之后添加
this.rendering = false;
Expand Down Expand Up @@ -457,7 +457,7 @@ export default class Scene extends EventEmitter implements ISceneService {

private handleMapCameraChanged = (viewport: IViewport) => {
this.cameraService.update(viewport);
this.render('mapRender');
this.render();
};

private addSceneEvent(target: IInteractionTarget) {
Expand Down
1 change: 0 additions & 1 deletion packages/layers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"author": "xiaoiver",
"license": "ISC",
"dependencies": {
"@antv/async-hook": "^2.1.0",
"@antv/geo-coord": "^1.0.8",
"@antv/l7-core": "^2.5.43",
"@antv/l7-source": "^2.5.43",
Expand Down
3 changes: 2 additions & 1 deletion packages/layers/src/core/BaseLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,8 @@ export default class BaseLayer<ChildLayerStyleOptions = {}> extends EventEmitter
}
public setIndex(index: number): ILayer {
this.zIndex = index;
this.layerService.updateRenderOrder();
this.layerService.updateLayerRenderList();
this.layerService.renderLayers();
return this;
}

Expand Down
1 change: 0 additions & 1 deletion packages/layers/src/plugins/LayerStylePlugin.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ILayer, ILayerPlugin, IMapService, TYPES } from '@antv/l7-core';
import { encodePickingColor, rgb2arr } from '@antv/l7-utils';
import { injectable } from 'inversify';
import 'reflect-metadata';
/**
Expand Down