diff --git a/packages/core/src/services/layer/ILayerService.ts b/packages/core/src/services/layer/ILayerService.ts index bc36c8e6e6..c27272ea1a 100644 --- a/packages/core/src/services/layer/ILayerService.ts +++ b/packages/core/src/services/layer/ILayerService.ts @@ -57,6 +57,7 @@ export interface ILayerModelInitializationOptions { vertexShader: string; fragmentShader: string; triangulation: Triangulation; + segmentNumber?: number; } export interface ILayerModel { diff --git a/packages/core/src/services/layer/IStyleAttributeService.ts b/packages/core/src/services/layer/IStyleAttributeService.ts index 2bfd8844d4..1eb6dc6902 100644 --- a/packages/core/src/services/layer/IStyleAttributeService.ts +++ b/packages/core/src/services/layer/IStyleAttributeService.ts @@ -161,6 +161,7 @@ export interface IStyleAttribute extends IStyleAttributeInitializationOptions { export type Triangulation = ( feature: IEncodeFeature, + segmentNumber?: number ) => { vertices: number[]; indices: number[]; @@ -197,6 +198,7 @@ export interface IStyleAttributeService { createAttributesAndIndices( encodedFeatures: IEncodeFeature[], triangulation?: Triangulation, + segmentNumber?: number ): { attributes: { [attributeName: string]: IAttribute; diff --git a/packages/core/src/services/layer/StyleAttributeService.ts b/packages/core/src/services/layer/StyleAttributeService.ts index 699036afd2..868de535ec 100644 --- a/packages/core/src/services/layer/StyleAttributeService.ts +++ b/packages/core/src/services/layer/StyleAttributeService.ts @@ -187,6 +187,7 @@ export default class StyleAttributeService implements IStyleAttributeService { public createAttributesAndIndices( features: IEncodeFeature[], triangulation: Triangulation, + segmentNumber: number ): { attributes: { [attributeName: string]: IAttribute; @@ -217,7 +218,7 @@ export default class StyleAttributeService implements IStyleAttributeService { vertices: verticesForCurrentFeature, normals: normalsForCurrentFeature, size: vertexSize, - } = this.triangulation(feature); + } = this.triangulation(feature, segmentNumber); indicesForCurrentFeature.forEach((i) => { indices.push(i + verticesNum); }); diff --git a/packages/layers/src/core/BaseLayer.ts b/packages/layers/src/core/BaseLayer.ts index d987ae15b4..4d85404d44 100644 --- a/packages/layers/src/core/BaseLayer.ts +++ b/packages/layers/src/core/BaseLayer.ts @@ -858,6 +858,7 @@ export default class BaseLayer extends EventEmitter vertexShader, fragmentShader, triangulation, + segmentNumber, ...rest } = options; this.shaderModuleService.registerModule(moduleName, { @@ -872,6 +873,7 @@ export default class BaseLayer extends EventEmitter } = this.styleAttributeService.createAttributesAndIndices( this.encodedData, triangulation, + segmentNumber ); return createModel({ attributes, diff --git a/packages/layers/src/core/triangulation.ts b/packages/layers/src/core/triangulation.ts index 483c6953f9..4a1ee485ad 100644 --- a/packages/layers/src/core/triangulation.ts +++ b/packages/layers/src/core/triangulation.ts @@ -202,8 +202,8 @@ export function RasterImageTriangulation(feature: IEncodeFeature) { * @param feature 映射数据 * @param segNum 弧线线段数 */ -export function LineArcTriangulation(feature: IEncodeFeature) { - const segNum = 30; +export function LineArcTriangulation(feature: IEncodeFeature, segmentNumber?: number) { + const segNum = segmentNumber ? segmentNumber : 30; const coordinates = feature.coordinates as IPosition[]; const positions = []; const indexArray = []; diff --git a/packages/layers/src/line/models/arc.ts b/packages/layers/src/line/models/arc.ts index 3d8fcc124b..87a7fdbfa9 100644 --- a/packages/layers/src/line/models/arc.ts +++ b/packages/layers/src/line/models/arc.ts @@ -132,6 +132,8 @@ export default class ArcModel extends BaseModel { } public buildModels(): IModel[] { + let { segmentNumber = 30 } = this.layer.getLayerConfig() as ILineLayerStyleOptions; + return [ this.layer.buildLayerModel({ moduleName: 'arc2dline', @@ -140,6 +142,7 @@ export default class ArcModel extends BaseModel { triangulation: LineArcTriangulation, depth: { enable: false }, blend: this.getBlend(), + segmentNumber }), ]; } diff --git a/stories/Map/components/amap2demo_arcLine.tsx b/stories/Map/components/amap2demo_arcLine.tsx index 698500b426..8493614fc9 100644 --- a/stories/Map/components/amap2demo_arcLine.tsx +++ b/stories/Map/components/amap2demo_arcLine.tsx @@ -44,7 +44,7 @@ export default class Amap2demo_arcLine extends React.Component { .style({ opacity: 0.8, blur: 0.99, - segmentNumber: 30 + segmentNumber: 3, // lineType: 'dash', // dashArray: [5, 5], });