mirror of https://gitee.com/antv-l7/antv-l7
parent
febd6e9994
commit
4137516862
|
@ -221,7 +221,7 @@ export default class PickingService implements IPickingService {
|
||||||
depth: 1,
|
depth: 1,
|
||||||
});
|
});
|
||||||
layer.hooks.beforePickingEncode.call();
|
layer.hooks.beforePickingEncode.call();
|
||||||
layer.renderModels();
|
layer.renderModels(true);
|
||||||
layer.hooks.afterPickingEncode.call();
|
layer.hooks.afterPickingEncode.call();
|
||||||
const isPicked = this.pickFromPickingFBO(layer, target);
|
const isPicked = this.pickFromPickingFBO(layer, target);
|
||||||
return isPicked && !layer.getLayerConfig().enablePropagation;
|
return isPicked && !layer.getLayerConfig().enablePropagation;
|
||||||
|
|
|
@ -147,7 +147,7 @@ export interface ILayer {
|
||||||
setCurrentSelectedId(id: number | null): void;
|
setCurrentSelectedId(id: number | null): void;
|
||||||
getCurrentSelectedId(): number | null;
|
getCurrentSelectedId(): number | null;
|
||||||
prepareBuildModel(): void;
|
prepareBuildModel(): void;
|
||||||
renderModels(): void;
|
renderModels(isPicking?: boolean): void;
|
||||||
buildModels(): void;
|
buildModels(): void;
|
||||||
rebuildModels(): void;
|
rebuildModels(): void;
|
||||||
buildLayerModel(
|
buildLayerModel(
|
||||||
|
|
|
@ -244,6 +244,6 @@ export interface IModelDrawOptions {
|
||||||
*/
|
*/
|
||||||
export interface IModel {
|
export interface IModel {
|
||||||
addUniforms(uniforms: { [key: string]: IUniform }): void;
|
addUniforms(uniforms: { [key: string]: IUniform }): void;
|
||||||
draw(options: IModelDrawOptions): void;
|
draw(options: IModelDrawOptions, pick?: boolean): void;
|
||||||
destroy(): void;
|
destroy(): void;
|
||||||
}
|
}
|
||||||
|
|
|
@ -963,7 +963,7 @@ export default class BaseLayer<ChildLayerStyleOptions = {}> extends EventEmitter
|
||||||
throw new Error('Method not implemented.');
|
throw new Error('Method not implemented.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public renderModels() {
|
public renderModels(isPicking?: boolean) {
|
||||||
// TODO: this.getEncodedData().length > 0 这个判断是为了解决在 2.5.x 引入数据纹理后产生的 空数据渲染导致 texture 超出上限问题
|
// TODO: this.getEncodedData().length > 0 这个判断是为了解决在 2.5.x 引入数据纹理后产生的 空数据渲染导致 texture 超出上限问题
|
||||||
if (this.getEncodedData().length > 0) {
|
if (this.getEncodedData().length > 0) {
|
||||||
if (this.layerModelNeedUpdate && this.layerModel) {
|
if (this.layerModelNeedUpdate && this.layerModel) {
|
||||||
|
@ -972,9 +972,12 @@ export default class BaseLayer<ChildLayerStyleOptions = {}> extends EventEmitter
|
||||||
this.layerModelNeedUpdate = false;
|
this.layerModelNeedUpdate = false;
|
||||||
}
|
}
|
||||||
this.models.forEach((model) => {
|
this.models.forEach((model) => {
|
||||||
model.draw({
|
model.draw(
|
||||||
uniforms: this.layerModel.getUninforms(),
|
{
|
||||||
});
|
uniforms: this.layerModel.getUninforms(),
|
||||||
|
},
|
||||||
|
isPicking,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
|
|
|
@ -7,7 +7,7 @@ import {
|
||||||
IUniform,
|
IUniform,
|
||||||
} from '@antv/l7-core';
|
} from '@antv/l7-core';
|
||||||
import regl from 'l7regl';
|
import regl from 'l7regl';
|
||||||
import { isPlainObject, isTypedArray } from 'lodash';
|
import { cloneDeep, isPlainObject, isTypedArray } from 'lodash';
|
||||||
import {
|
import {
|
||||||
blendEquationMap,
|
blendEquationMap,
|
||||||
blendFuncMap,
|
blendFuncMap,
|
||||||
|
@ -29,6 +29,7 @@ export default class ReglModel implements IModel {
|
||||||
private reGl: regl.Regl;
|
private reGl: regl.Regl;
|
||||||
private destroyed: boolean = false;
|
private destroyed: boolean = false;
|
||||||
private drawCommand: regl.DrawCommand;
|
private drawCommand: regl.DrawCommand;
|
||||||
|
private drawPickCommand: regl.DrawCommand;
|
||||||
private drawParams: regl.DrawConfig;
|
private drawParams: regl.DrawConfig;
|
||||||
private options: IModelInitializationOptions;
|
private options: IModelInitializationOptions;
|
||||||
private uniforms: {
|
private uniforms: {
|
||||||
|
@ -93,6 +94,18 @@ export default class ReglModel implements IModel {
|
||||||
this.initCullDrawParams({ cull }, drawParams);
|
this.initCullDrawParams({ cull }, drawParams);
|
||||||
|
|
||||||
this.drawCommand = reGl(drawParams);
|
this.drawCommand = reGl(drawParams);
|
||||||
|
|
||||||
|
const pickDrawParams = cloneDeep(drawParams);
|
||||||
|
// @ts-ignore
|
||||||
|
pickDrawParams.blend.enable = true;
|
||||||
|
// @ts-ignore
|
||||||
|
pickDrawParams.blend.func = {
|
||||||
|
dstAlpha: 'one',
|
||||||
|
dstRGB: 'one minus src alpha',
|
||||||
|
srcAlpha: 'one',
|
||||||
|
srcRGB: 'src alpha',
|
||||||
|
};
|
||||||
|
this.drawPickCommand = reGl(pickDrawParams);
|
||||||
this.drawParams = drawParams;
|
this.drawParams = drawParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +116,8 @@ export default class ReglModel implements IModel {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public draw(options: IModelDrawOptions) {
|
public draw(options: IModelDrawOptions, pick?: boolean) {
|
||||||
|
// console.log('options', this.drawParams)
|
||||||
if (
|
if (
|
||||||
this.drawParams.attributes &&
|
this.drawParams.attributes &&
|
||||||
Object.keys(this.drawParams.attributes).length === 0
|
Object.keys(this.drawParams.attributes).length === 0
|
||||||
|
@ -143,7 +157,14 @@ export default class ReglModel implements IModel {
|
||||||
| ReglTexture2D).get();
|
| ReglTexture2D).get();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.drawCommand(reglDrawProps);
|
// TODO: 在进行拾取操作的绘制中,不应该使用叠加模式 - picking 根据拾取的颜色作为判断的输入,而叠加模式会产生新的,在 id 序列中不存在的颜色
|
||||||
|
if (!pick) {
|
||||||
|
this.drawCommand(reglDrawProps);
|
||||||
|
} else {
|
||||||
|
this.drawPickCommand(reglDrawProps);
|
||||||
|
}
|
||||||
|
// this.drawCommand(reglDrawProps);
|
||||||
|
// this.drawPickCommand(reglDrawProps);
|
||||||
}
|
}
|
||||||
|
|
||||||
public destroy() {
|
public destroy() {
|
||||||
|
|
|
@ -28,7 +28,7 @@ export default class GaodeMapComponent extends React.Component {
|
||||||
// min = 'min',
|
// min = 'min',
|
||||||
// max = 'max',
|
// max = 'max',
|
||||||
// none = 'none',
|
// none = 'none',
|
||||||
const layer = new PointLayer({ zIndex: 2, blend: 'additive' })
|
const layer = new PointLayer({ zIndex: 2, blend: 'additive' }) //
|
||||||
.source(
|
.source(
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue