Skip to content

Commit

Permalink
Feat: fillImage&radar update to G-Engine (#2107)
Browse files Browse the repository at this point in the history
* feat: 切换fillImage到G引擎

* feat: 补充上体提交代码

* feat: radar和fillImage支持G引擎(有bug)

* fix: 调整radar中uniform块中对象的顺序(遍历时一般按照unicode排序)

* fix: 修改radar shader中的拼写错误

---------

Co-authored-by: huyang <[email protected]>
  • Loading branch information
taiyuanhy and huyang authored Dec 1, 2023
1 parent 26b2a79 commit f7d7b62
Show file tree
Hide file tree
Showing 16 changed files with 197 additions and 152 deletions.
132 changes: 67 additions & 65 deletions dev-demos/features/point/demos/radar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export default () => {
useEffect( () => {
const scene = new Scene({
id: 'map',
renderer: 'device',
map: new GaodeMap({
center: [120.188193, 30.292542],
pitch: 0,
Expand Down Expand Up @@ -77,82 +78,83 @@ export default () => {
.shape('radar')
.style({
unit:'meter',
speed:5
})
.animate(false)
.animate(true)
.active(true);

const layer2 = new PointLayer()
.source(
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [120.188193, 30.292542]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [120.201665, 30.26873]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [120.225209, 30.290802]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [120.189641, 30.293248]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [120.189389, 30.292542]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [120.190837, 30.293303]
}
}
]
}
// const layer2 = new PointLayer()
// .source(
// {
// "type": "FeatureCollection",
// "features": [
// {
// "type": "Feature",
// "properties": {},
// "geometry": {
// "type": "Point",
// "coordinates": [120.188193, 30.292542]
// }
// },
// {
// "type": "Feature",
// "properties": {},
// "geometry": {
// "type": "Point",
// "coordinates": [120.201665, 30.26873]
// }
// },
// {
// "type": "Feature",
// "properties": {},
// "geometry": {
// "type": "Point",
// "coordinates": [120.225209, 30.290802]
// }
// },
// {
// "type": "Feature",
// "properties": {},
// "geometry": {
// "type": "Point",
// "coordinates": [120.189641, 30.293248]
// }
// },
// {
// "type": "Feature",
// "properties": {},
// "geometry": {
// "type": "Point",
// "coordinates": [120.189389, 30.292542]
// }
// },
// {
// "type": "Feature",
// "properties": {},
// "geometry": {
// "type": "Point",
// "coordinates": [120.190837, 30.293303]
// }
// }
// ]
// }

)
.size(5)
.color('#0f0')
.shape('circle')
.style({
unit:'pixel',
})
.active(true);
// )
// .size(5)
// .color('#0f0')
// .shape('circle')
// .style({
// unit:'pixel',
// })
// .active(true);





scene.on('loaded', () => {
scene.addLayer(layer);
scene.addLayer(layer2);
// scene.addLayer(layer2);
});

}, []);
Expand Down
5 changes: 5 additions & 0 deletions dev-demos/features/point/pointRadar.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
---
group:
title:
order: 1
---
### point - radar
<code src="./demos/radar.tsx"></code>
2 changes: 1 addition & 1 deletion packages/core/src/services/layer/IStyleAttributeService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
} from '../renderer/IAttribute';
import { IBufferInitializationOptions } from '../renderer/IBuffer';
import { IElements } from '../renderer/IElements';
import { ILayer, ILayerConfig } from './ILayerService';
import { ILayer } from './ILayerService';

/**
* 1. 提供各个 Layer 样式属性初始值的注册服务
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/services/layer/StyleAttributeService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { IAttribute } from '../renderer/IAttribute';
import { IElements } from '../renderer/IElements';
import { IRendererService } from '../renderer/IRendererService';
import { gl } from '../renderer/gl';
import { ILayer, ILayerConfig } from './ILayerService';
import { ILayer } from './ILayerService';
import {
IAttributeScale,
IEncodeFeature,
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/services/renderer/IModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ export interface IModelDrawOptions {
blend?: Partial<IBlendOptions>;

stencil?: Partial<IStencilOptions>;

textures?:ITexture2D[]
}

/**
Expand Down
1 change: 1 addition & 0 deletions packages/layers/src/core/BaseLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1385,6 +1385,7 @@ export default class BaseLayer<ChildLayerStyleOptions = {}>
uniforms: this.layerModel.getUninforms(),
blend: this.layerModel.getBlend(),
stencil: this.layerModel.getStencil(options),
textures:this.layerModel.textures
},
options?.ispick || false,
);
Expand Down
2 changes: 1 addition & 1 deletion packages/layers/src/core/BaseModel.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

import {
BlendType,
IAnimateOption,
Expand Down Expand Up @@ -195,7 +196,6 @@ export default class BaseModel<ChildLayerStyleOptions = {}>
public getUninforms(): IModelUniform {
throw new Error('Method not implemented.');
}

public getAnimateUniforms(): IModelUniform {
return {};
}
Expand Down
1 change: 1 addition & 0 deletions packages/layers/src/core/CommonStyleAttribute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export enum ShaderLocation {
EXTRUDE,
MAX,
NORMAL,
UV
}

export function getCommonStyleAttributeOptions(
Expand Down
2 changes: 1 addition & 1 deletion packages/layers/src/line/models/wall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
IModelUniform,
ITexture2D,
} from '@antv/l7-core';
import { lodashUtil, rgb2arr } from '@antv/l7-utils';
import { rgb2arr } from '@antv/l7-utils';
import BaseModel from '../../core/BaseModel';
import { ILineLayerStyleOptions } from '../../core/interface';
import { LineTriangulation } from '../../core/triangulation';
Expand Down
32 changes: 22 additions & 10 deletions packages/layers/src/point/models/fillmage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,24 @@ import { PointFillTriangulation } from '../../core/triangulation';
// static pointLayer shader - not support animate
import pointFillFrag from '../shaders/image/fillImage_frag.glsl';
import pointFillVert from '../shaders/image/fillImage_vert.glsl';
import { ShaderLocation } from '../../core/CommonStyleAttribute';

export default class FillImageModel extends BaseModel {
private meter2coord: number = 1;
private texture: ITexture2D;
private isMeter: boolean = false;
private radian: number = 0; // 旋转的弧度
public getUninforms(): IModelUniform {
const commoninfo = this.getCommonUniformsInfo();
const attributeInfo = this.getUniformsBufferInfo(this.getStyleAttribute());
this.updateStyleUnifoms();
return {
...commoninfo.uniformsOption,
...attributeInfo.uniformsOption,
...{u_texture:this.texture}
}
}
protected getCommonUniformsInfo(): { uniformsArray: number[]; uniformsLength: number; uniformsOption:{[key: string]: any} } {
const {
raisingHeight = 0.0,
heightfixed = false,
Expand All @@ -39,20 +50,16 @@ export default class FillImageModel extends BaseModel {
* GAODE1.x -1
*/

return {
u_raisingHeight: Number(raisingHeight),
const commonOptions = {
u_heightfixed: Number(heightfixed),
u_raisingHeight: Number(raisingHeight),
u_size_unit: SizeUnitType[unit] as SizeUnitType,

u_texture: this.texture,
u_textSize: [1024, this.iconService.canvasHeight || 128],

// u_opacity: opacity,
// u_offsets: offsets,
...this.getStyleAttribute(),
u_textSize: [1024, this.iconService.canvasHeight || 128]
};
const commonBufferInfo = this.getUniformsBufferInfo(commonOptions);

return commonBufferInfo;
}

public getAttribute(): {
attributes: {
[attributeName: string]: IAttribute;
Expand All @@ -72,6 +79,7 @@ export default class FillImageModel extends BaseModel {
}

public async buildModels(): Promise<IModel[]> {
this.initUniformsBuffer();
const model = await this.layer.buildLayerModel({
moduleName: 'pointFillImage',
vertexShader: pointFillVert,
Expand Down Expand Up @@ -99,6 +107,7 @@ export default class FillImageModel extends BaseModel {
type: AttributeType.Attribute,
descriptor: {
name: 'a_Uv',
shaderLocation:ShaderLocation.UV,
buffer: {
// give the WebGL driver a hint that this buffer may change
usage: gl.DYNAMIC_DRAW,
Expand All @@ -120,6 +129,7 @@ export default class FillImageModel extends BaseModel {
type: AttributeType.Attribute,
descriptor: {
name: 'a_Extrude',
shaderLocation: ShaderLocation.EXTRUDE,
buffer: {
// give the WebGL driver a hint that this buffer may change
usage: gl.DYNAMIC_DRAW,
Expand Down Expand Up @@ -151,6 +161,7 @@ export default class FillImageModel extends BaseModel {
type: AttributeType.Attribute,
descriptor: {
name: 'a_Size',
shaderLocation: ShaderLocation.SIZE,
buffer: {
// give the WebGL driver a hint that this buffer may change
usage: gl.DYNAMIC_DRAW,
Expand Down Expand Up @@ -188,5 +199,6 @@ export default class FillImageModel extends BaseModel {
height: this.iconService.canvasHeight || 128,
mipmap: true,
});
this.textures = [this.texture];
};
}
Loading

0 comments on commit f7d7b62

Please sign in to comment.