From e44ba06eae490668aba38dfd95787a97c3480421 Mon Sep 17 00:00:00 2001 From: YiQianYao <42212176+2912401452@users.noreply.github.com> Date: Fri, 6 May 2022 20:12:55 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20sprite=20=E4=BC=98=E5=8C=96=EF=BC=8C?= =?UTF-8?q?=E5=8F=96=E6=B6=88=E6=8B=BE=E5=8F=96=EF=BC=8C=E5=85=81=E8=AE=B8?= =?UTF-8?q?=E4=B8=8D=E8=AE=BE=E7=BD=AE=20source=20(#1098)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: 修改 StyleAttributeField 的类型定义,允许图层在未设置 source 的时候设置 size * feat: sprite cancel picking capacity --- .../src/services/layer/IStyleAttributeService.ts | 2 +- .../layers/src/Geometry/shaders/sprite_frag.glsl | 3 --- .../layers/src/Geometry/shaders/sprite_vert.glsl | 3 --- packages/layers/src/plugins/FeatureScalePlugin.ts | 2 +- stories/Object/components/sprite.tsx | 15 ++++++++------- 5 files changed, 10 insertions(+), 15 deletions(-) diff --git a/packages/core/src/services/layer/IStyleAttributeService.ts b/packages/core/src/services/layer/IStyleAttributeService.ts index a33101d141..ad7abab1b4 100644 --- a/packages/core/src/services/layer/IStyleAttributeService.ts +++ b/packages/core/src/services/layer/IStyleAttributeService.ts @@ -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 { diff --git a/packages/layers/src/Geometry/shaders/sprite_frag.glsl b/packages/layers/src/Geometry/shaders/sprite_frag.glsl index 42f5eb751c..012ef3c87c 100644 --- a/packages/layers/src/Geometry/shaders/sprite_frag.glsl +++ b/packages/layers/src/Geometry/shaders/sprite_frag.glsl @@ -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); } diff --git a/packages/layers/src/Geometry/shaders/sprite_vert.glsl b/packages/layers/src/Geometry/shaders/sprite_vert.glsl index bb25031536..5caf500f3c 100644 --- a/packages/layers/src/Geometry/shaders/sprite_vert.glsl +++ b/packages/layers/src/Geometry/shaders/sprite_vert.glsl @@ -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); } diff --git a/packages/layers/src/plugins/FeatureScalePlugin.ts b/packages/layers/src/plugins/FeatureScalePlugin.ts index 1e91e3ddc8..0b03128ec8 100644 --- a/packages/layers/src/plugins/FeatureScalePlugin.ts +++ b/packages/layers/src/plugins/FeatureScalePlugin.ts @@ -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; diff --git a/stories/Object/components/sprite.tsx b/stories/Object/components/sprite.tsx index db6af567aa..37ee983f7e 100644 --- a/stories/Object/components/sprite.tsx +++ b/stories/Object/components/sprite.tsx @@ -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', () => {