feat: sprite 优化,取消拾取,允许不设置 source (#1098)

* refactor: 修改 StyleAttributeField 的类型定义,允许图层在未设置 source 的时候设置 size

* feat: sprite cancel picking capacity
This commit is contained in:
YiQianYao 2022-05-06 20:12:55 +08:00 committed by GitHub
parent 936ac40d36
commit e44ba06eae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 15 deletions

View File

@ -118,7 +118,7 @@ export interface IVertexAttributeDescriptor
export type Position = number[];
type Color = [number, number, number, number];
type CallBack = (...args: any[]) => any;
export type StyleAttributeField = string | string[] | number[];
export type StyleAttributeField = string | string[] | number[] | number;
export type StyleAttributeOption = string | number | boolean | any[] | CallBack;
export type StyleAttrField = string | string[] | number | number[];
export interface IAttributeScale {

View File

@ -6,7 +6,6 @@ uniform float u_opacity;
varying vec3 v_Color;
varying float v_d;
#pragma include "picking"
void main() {
if(v_d < 0.0) {
@ -19,6 +18,4 @@ void main() {
} else {
gl_FragColor = vec4(v_Color, u_opacity);
}
gl_FragColor = filterColor(gl_FragColor);
}

View File

@ -11,7 +11,6 @@ varying vec3 v_Color;
varying float v_d;
#pragma include "projection"
#pragma include "picking"
void main() {
v_Color = a_Color;
@ -26,6 +25,4 @@ void main() {
}
gl_PointSize = pow((u_Zoom - 1.0), 2.0) * u_Scale;
setPickingColor(a_PickingColor);
}

View File

@ -183,7 +183,7 @@ export default class FeatureScalePlugin implements ILayerPlugin {
* 'w' => ['w']
*/
private parseFields(
field: string[] | string | number[],
field: string[] | string | number[] | number,
): string[] | number[] {
if (Array.isArray(field)) {
return field;

View File

@ -25,13 +25,13 @@ export default class Demo extends React.Component {
this.scene = scene;
let layer = new GeometryLayer()
.source([{ lng: 120, lat: 30 }], {
parser: {
type: 'json',
x: 'lng',
y: 'lat',
},
})
// .source([{ lng: 120, lat: 30 }], {
// parser: {
// type: 'json',
// x: 'lng',
// y: 'lat',
// },
// })
.shape('sprite')
.size(10)
.style({
@ -50,6 +50,7 @@ export default class Demo extends React.Component {
spriteScale: 0.6,
// spriteUpdate: 20000
})
.active(true)
.color('#f00');
scene.on('loaded', () => {