mirror of https://gitee.com/antv-l7/antv-l7
parent
f45c6a19d1
commit
669e4f418e
|
@ -663,6 +663,7 @@ export interface ILayerService {
|
|||
removeAllLayers(): void;
|
||||
updateLayerRenderList(): void;
|
||||
reRender(): void;
|
||||
renderMask(masks:ILayer[]):Promise<void[]>;
|
||||
throttleRenderLayers(): void;
|
||||
renderLayers(): void;
|
||||
setEnableRender(flag: boolean): void;
|
||||
|
|
|
@ -64,7 +64,9 @@ export default class LayerService implements ILayerService {
|
|||
|
||||
public addMask(mask: ILayer) {
|
||||
if (this.sceneInited) {
|
||||
mask.init();
|
||||
mask.init().then(() => {
|
||||
this.renderLayers();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,34 +145,38 @@ export default class LayerService implements ILayerService {
|
|||
for (const layer of this.layerList) {
|
||||
await layer.hooks.beforeRenderData.promise();
|
||||
layer.hooks.beforeRender.call();
|
||||
|
||||
if (layer.masks.length > 0) {
|
||||
if (layer.masks.filter((m)=>m.inited).length > 0) {
|
||||
// 清除上一次的模版缓存
|
||||
this.renderService.clear({
|
||||
stencil: 0,
|
||||
depth: 1,
|
||||
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) {
|
||||
// multiPassRender 不是同步渲染完成的
|
||||
await layer.renderMultiPass();
|
||||
} else {
|
||||
layer.render();
|
||||
|
||||
}
|
||||
layer.hooks.afterRender.call();
|
||||
}
|
||||
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() {
|
||||
// Tip: 每次更新都是从 layers 重新构建
|
||||
|
|
|
@ -234,7 +234,7 @@ export default class BaseLayer<ChildLayerStyleOptions = {}>
|
|||
this.name = config.name || this.id;
|
||||
this.zIndex = config.zIndex || 0;
|
||||
this.rawConfig = config;
|
||||
this.parent = this;
|
||||
// this.parent = this;
|
||||
}
|
||||
|
||||
public addMaskLayer(maskLayer: ILayer) {
|
||||
|
|
|
@ -29,13 +29,12 @@ export default class LayerModelPlugin implements ILayerPlugin {
|
|||
});
|
||||
|
||||
layer.hooks.beforeRenderData.tapPromise(
|
||||
'DataSourcePlugin',
|
||||
'LayerModelPlugin',
|
||||
async (flag: boolean) => {
|
||||
if (!flag) {
|
||||
return flag;
|
||||
return false;
|
||||
}
|
||||
await this.prepareLayerModel(layer);
|
||||
return false;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ export class Base {
|
|||
private tileLayerCache: Map<string, ILayer[]> = new Map();
|
||||
|
||||
private async initTileLayers(layers: ILayer[], tile: SourceTile) {
|
||||
layers.map(async (layer) => {
|
||||
return Promise.all(layers.map(async (layer) => {
|
||||
const container = createLayerContainer(
|
||||
this.parent.sceneContainer as Container,
|
||||
);
|
||||
|
@ -31,7 +31,7 @@ export class Base {
|
|||
this.addChild(layer);
|
||||
tile.layerLoad();
|
||||
this.render()
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
public render() {
|
||||
|
|
|
@ -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 'reflect-metadata';
|
||||
import Tile from '../tileFactory/Tile';
|
||||
|
||||
interface TileLayerServiceOptions {
|
||||
rendererService: IRendererService;
|
||||
layerService: ILayerService
|
||||
parent:ILayer;
|
||||
}
|
||||
export class TileLayerService {
|
||||
private rendererService: IRendererService;
|
||||
private layerService: ILayerService;
|
||||
private parent: ILayer;
|
||||
|
||||
public colorTexture: ITexture2D; // 颜色纹理,被栅格瓦片共用
|
||||
|
||||
private _tiles: Tile[] = [];
|
||||
constructor({ rendererService, parent }: TileLayerServiceOptions) {
|
||||
constructor({ rendererService,layerService, parent }: TileLayerServiceOptions) {
|
||||
this.rendererService = rendererService;
|
||||
this.layerService =layerService;
|
||||
this.parent = parent;
|
||||
}
|
||||
get tiles():Tile[] {
|
||||
|
@ -49,6 +52,10 @@ export class TileLayerService {
|
|||
const tile = this.getTile(sourceTile.key);
|
||||
tile?.updateVisible(sourceTile.isVisible);
|
||||
|
||||
}
|
||||
beforeRender() {
|
||||
// TODO 统一处理状态更新 attribute style
|
||||
|
||||
}
|
||||
|
||||
render() {
|
||||
|
@ -78,12 +85,7 @@ export class TileLayerService {
|
|||
depth: 1,
|
||||
framebuffer: null,
|
||||
});
|
||||
layer.masks.map(async (m: ILayer) => {
|
||||
await m.hooks.beforeRenderData.promise();
|
||||
m.hooks.beforeRender.call();
|
||||
m.render();
|
||||
m.hooks.afterRender.call();
|
||||
});
|
||||
this.layerService.renderMask(layer.masks)
|
||||
}
|
||||
if (layer.getLayerConfig().enableMultiPassRenderer) {
|
||||
// multiPassRender 不是同步渲染完成的
|
||||
|
|
|
@ -40,4 +40,8 @@ export class TilePickService {
|
|||
});
|
||||
});
|
||||
}
|
||||
/** 从瓦片中根据数据 */
|
||||
getFeatureById() {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import { SourceTile, TilesetManager } from '@antv/l7-utils';
|
|||
import { setStyleAttributeField, setScale } from '../style/utils';
|
||||
import { registerLayers } from '../utils';
|
||||
import { readRasterValue } from '../interaction/getRasterData';
|
||||
import VectorLayer from './layers/VectorLayer';
|
||||
import VectorLayer from './layers/vectorLayer';
|
||||
|
||||
import * as turf from '@turf/helpers';
|
||||
import union from '@turf/union';
|
||||
|
|
|
@ -44,6 +44,7 @@ export class TileLayer extends Base implements ITileLayer {
|
|||
// 初始化瓦片管理服务
|
||||
this.tileLayerService = new TileLayerService({
|
||||
rendererService,
|
||||
layerService,
|
||||
parent
|
||||
})
|
||||
// 初始化拾取服务
|
||||
|
|
|
@ -234,14 +234,7 @@ export default class WindModel extends BaseModel {
|
|||
|
||||
private drawColorMode() {
|
||||
const { opacity } = this.layer.getLayerConfig() as IWindLayerStyleOptions;
|
||||
|
||||
this.layer.masks.map(async (m) => {
|
||||
await m.hooks.beforeRenderData.promise();
|
||||
m.hooks.beforeRender.call();
|
||||
m.render();
|
||||
m.hooks.afterRender.call();
|
||||
});
|
||||
|
||||
this.layerService.renderMask(this.layer.masks)
|
||||
this.colorModel?.draw({
|
||||
uniforms: {
|
||||
u_opacity: opacity || 1.0,
|
||||
|
|
|
@ -213,7 +213,7 @@ class Scene
|
|||
const layerContainer = createLayerContainer(this.container);
|
||||
mask.setContainer(layerContainer, this.container);
|
||||
parent.addMaskLayer(mask);
|
||||
this.sceneService.addLayer(mask);
|
||||
this.sceneService.addMask(mask);
|
||||
} else {
|
||||
console.warn('parent layer not find!');
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue