mirror of https://gitee.com/antv-l7/antv-l7
feat: 增加 arc 弧线的分段数控制
This commit is contained in:
parent
3e05aeae71
commit
a7314f8f9e
|
@ -57,6 +57,7 @@ export interface ILayerModelInitializationOptions {
|
|||
vertexShader: string;
|
||||
fragmentShader: string;
|
||||
triangulation: Triangulation;
|
||||
segmentNumber?: number;
|
||||
}
|
||||
|
||||
export interface ILayerModel {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
|
@ -858,6 +858,7 @@ export default class BaseLayer<ChildLayerStyleOptions = {}> extends EventEmitter
|
|||
vertexShader,
|
||||
fragmentShader,
|
||||
triangulation,
|
||||
segmentNumber,
|
||||
...rest
|
||||
} = options;
|
||||
this.shaderModuleService.registerModule(moduleName, {
|
||||
|
@ -872,6 +873,7 @@ export default class BaseLayer<ChildLayerStyleOptions = {}> extends EventEmitter
|
|||
} = this.styleAttributeService.createAttributesAndIndices(
|
||||
this.encodedData,
|
||||
triangulation,
|
||||
segmentNumber
|
||||
);
|
||||
return createModel({
|
||||
attributes,
|
||||
|
|
|
@ -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 = [];
|
||||
|
|
|
@ -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
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
|
|
@ -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],
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue