chore: 合并冲突 (#1407)

* fix: 拾取操作

* fix: 文件大小写

* fix: mask map async
This commit is contained in:
@thinkinggis 2022-10-19 14:14:05 +08:00 committed by GitHub
parent f45c6a19d1
commit 669e4f418e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 41 additions and 35 deletions

View File

@ -663,6 +663,7 @@ export interface ILayerService {
removeAllLayers(): void; removeAllLayers(): void;
updateLayerRenderList(): void; updateLayerRenderList(): void;
reRender(): void; reRender(): void;
renderMask(masks:ILayer[]):Promise<void[]>;
throttleRenderLayers(): void; throttleRenderLayers(): void;
renderLayers(): void; renderLayers(): void;
setEnableRender(flag: boolean): void; setEnableRender(flag: boolean): void;

View File

@ -64,7 +64,9 @@ export default class LayerService implements ILayerService {
public addMask(mask: ILayer) { public addMask(mask: ILayer) {
if (this.sceneInited) { if (this.sceneInited) {
mask.init(); mask.init().then(() => {
this.renderLayers();
});
} }
} }
@ -143,35 +145,39 @@ export default class LayerService implements ILayerService {
for (const layer of this.layerList) { for (const layer of this.layerList) {
await layer.hooks.beforeRenderData.promise(); await layer.hooks.beforeRenderData.promise();
layer.hooks.beforeRender.call(); layer.hooks.beforeRender.call();
if (layer.masks.filter((m)=>m.inited).length > 0) {
if (layer.masks.length > 0) {
// 清除上一次的模版缓存 // 清除上一次的模版缓存
this.renderService.clear({ this.renderService.clear({
stencil: 0, stencil: 0,
depth: 1, depth: 1,
framebuffer: null, framebuffer: null,
}); });
layer.masks.map(async (m: ILayer) => {
// console.time('t')
await m.hooks.beforeRenderData.promise();
// console.timeEnd('t')
m.hooks.beforeRender.call();
m.render();
m.hooks.afterRender.call();
});
} }
await this.renderMask(layer.masks)
if (layer.getLayerConfig().enableMultiPassRenderer) { if (layer.getLayerConfig().enableMultiPassRenderer) {
// multiPassRender 不是同步渲染完成的 // multiPassRender 不是同步渲染完成的
await layer.renderMultiPass(); await layer.renderMultiPass();
} else { } else {
layer.render(); layer.render();
} }
layer.hooks.afterRender.call(); layer.hooks.afterRender.call();
} }
this.alreadyInRendering = false; this.alreadyInRendering = false;
} }
public async renderMask(masks:ILayer[]):Promise<void[]> {
return Promise.all(masks.map(async (m: ILayer) => {
await m.hooks.beforeRenderData.promise();
m.hooks.beforeRender.call();
m.render();
m.hooks.afterRender.call();
}));
}
public updateLayerRenderList() { public updateLayerRenderList() {
// Tip: 每次更新都是从 layers 重新构建 // Tip: 每次更新都是从 layers 重新构建
this.layerList = []; this.layerList = [];

View File

@ -234,7 +234,7 @@ export default class BaseLayer<ChildLayerStyleOptions = {}>
this.name = config.name || this.id; this.name = config.name || this.id;
this.zIndex = config.zIndex || 0; this.zIndex = config.zIndex || 0;
this.rawConfig = config; this.rawConfig = config;
this.parent = this; // this.parent = this;
} }
public addMaskLayer(maskLayer: ILayer) { public addMaskLayer(maskLayer: ILayer) {

View File

@ -29,13 +29,12 @@ export default class LayerModelPlugin implements ILayerPlugin {
}); });
layer.hooks.beforeRenderData.tapPromise( layer.hooks.beforeRenderData.tapPromise(
'DataSourcePlugin', 'LayerModelPlugin',
async (flag: boolean) => { async (flag: boolean) => {
if (!flag) { if (!flag) {
return flag; return false;
} }
await this.prepareLayerModel(layer); await this.prepareLayerModel(layer);
return false;
}, },
); );
} }

View File

@ -22,7 +22,7 @@ export class Base {
private tileLayerCache: Map<string, ILayer[]> = new Map(); private tileLayerCache: Map<string, ILayer[]> = new Map();
private async initTileLayers(layers: ILayer[], tile: SourceTile) { private async initTileLayers(layers: ILayer[], tile: SourceTile) {
layers.map(async (layer) => { return Promise.all(layers.map(async (layer) => {
const container = createLayerContainer( const container = createLayerContainer(
this.parent.sceneContainer as Container, this.parent.sceneContainer as Container,
); );
@ -31,7 +31,7 @@ export class Base {
this.addChild(layer); this.addChild(layer);
tile.layerLoad(); tile.layerLoad();
this.render() this.render()
}); }));
} }
public render() { public render() {

View File

@ -1,21 +1,24 @@
import { ILayer, ILngLat, IRendererService, ITexture2D } from '@antv/l7-core'; import { ILayer, ILayerService, ILngLat, IRendererService, ITexture2D } from '@antv/l7-core';
import { SourceTile } from '@antv/l7-utils'; import { SourceTile } from '@antv/l7-utils';
import 'reflect-metadata'; import 'reflect-metadata';
import Tile from '../tileFactory/Tile'; import Tile from '../tileFactory/Tile';
interface TileLayerServiceOptions { interface TileLayerServiceOptions {
rendererService: IRendererService; rendererService: IRendererService;
layerService: ILayerService
parent:ILayer; parent:ILayer;
} }
export class TileLayerService { export class TileLayerService {
private rendererService: IRendererService; private rendererService: IRendererService;
private layerService: ILayerService;
private parent: ILayer; private parent: ILayer;
public colorTexture: ITexture2D; // 颜色纹理,被栅格瓦片共用 public colorTexture: ITexture2D; // 颜色纹理,被栅格瓦片共用
private _tiles: Tile[] = []; private _tiles: Tile[] = [];
constructor({ rendererService, parent }: TileLayerServiceOptions) { constructor({ rendererService,layerService, parent }: TileLayerServiceOptions) {
this.rendererService = rendererService; this.rendererService = rendererService;
this.layerService =layerService;
this.parent = parent; this.parent = parent;
} }
get tiles():Tile[] { get tiles():Tile[] {
@ -49,6 +52,10 @@ export class TileLayerService {
const tile = this.getTile(sourceTile.key); const tile = this.getTile(sourceTile.key);
tile?.updateVisible(sourceTile.isVisible); tile?.updateVisible(sourceTile.isVisible);
}
beforeRender() {
// TODO 统一处理状态更新 attribute style
} }
render() { render() {
@ -78,12 +85,7 @@ export class TileLayerService {
depth: 1, depth: 1,
framebuffer: null, framebuffer: null,
}); });
layer.masks.map(async (m: ILayer) => { this.layerService.renderMask(layer.masks)
await m.hooks.beforeRenderData.promise();
m.hooks.beforeRender.call();
m.render();
m.hooks.afterRender.call();
});
} }
if (layer.getLayerConfig().enableMultiPassRenderer) { if (layer.getLayerConfig().enableMultiPassRenderer) {
// multiPassRender 不是同步渲染完成的 // multiPassRender 不是同步渲染完成的

View File

@ -40,4 +40,8 @@ export class TilePickService {
}); });
}); });
} }
/** 从瓦片中根据数据 */
getFeatureById() {
}
} }

View File

@ -10,7 +10,7 @@ import { SourceTile, TilesetManager } from '@antv/l7-utils';
import { setStyleAttributeField, setScale } from '../style/utils'; import { setStyleAttributeField, setScale } from '../style/utils';
import { registerLayers } from '../utils'; import { registerLayers } from '../utils';
import { readRasterValue } from '../interaction/getRasterData'; import { readRasterValue } from '../interaction/getRasterData';
import VectorLayer from './layers/VectorLayer'; import VectorLayer from './layers/vectorLayer';
import * as turf from '@turf/helpers'; import * as turf from '@turf/helpers';
import union from '@turf/union'; import union from '@turf/union';

View File

@ -44,6 +44,7 @@ export class TileLayer extends Base implements ITileLayer {
// 初始化瓦片管理服务 // 初始化瓦片管理服务
this.tileLayerService = new TileLayerService({ this.tileLayerService = new TileLayerService({
rendererService, rendererService,
layerService,
parent parent
}) })
// 初始化拾取服务 // 初始化拾取服务

View File

@ -234,14 +234,7 @@ export default class WindModel extends BaseModel {
private drawColorMode() { private drawColorMode() {
const { opacity } = this.layer.getLayerConfig() as IWindLayerStyleOptions; const { opacity } = this.layer.getLayerConfig() as IWindLayerStyleOptions;
this.layerService.renderMask(this.layer.masks)
this.layer.masks.map(async (m) => {
await m.hooks.beforeRenderData.promise();
m.hooks.beforeRender.call();
m.render();
m.hooks.afterRender.call();
});
this.colorModel?.draw({ this.colorModel?.draw({
uniforms: { uniforms: {
u_opacity: opacity || 1.0, u_opacity: opacity || 1.0,

View File

@ -213,7 +213,7 @@ class Scene
const layerContainer = createLayerContainer(this.container); const layerContainer = createLayerContainer(this.container);
mask.setContainer(layerContainer, this.container); mask.setContainer(layerContainer, this.container);
parent.addMaskLayer(mask); parent.addMaskLayer(mask);
this.sceneService.addLayer(mask); this.sceneService.addMask(mask);
} else { } else {
console.warn('parent layer not find!'); console.warn('parent layer not find!');
} }