This commit is contained in:
2912401452 2021-09-02 13:54:08 +08:00
commit a0b1af5644
9 changed files with 26 additions and 8 deletions

View File

@ -57,6 +57,7 @@ export interface ILayerModelInitializationOptions {
vertexShader: string; vertexShader: string;
fragmentShader: string; fragmentShader: string;
triangulation: Triangulation; triangulation: Triangulation;
segmentNumber?: number;
} }
export interface ILayerModel { export interface ILayerModel {

View File

@ -161,6 +161,7 @@ export interface IStyleAttribute extends IStyleAttributeInitializationOptions {
export type Triangulation = ( export type Triangulation = (
feature: IEncodeFeature, feature: IEncodeFeature,
segmentNumber?: number,
) => { ) => {
vertices: number[]; vertices: number[];
indices: number[]; indices: number[];
@ -197,6 +198,7 @@ export interface IStyleAttributeService {
createAttributesAndIndices( createAttributesAndIndices(
encodedFeatures: IEncodeFeature[], encodedFeatures: IEncodeFeature[],
triangulation?: Triangulation, triangulation?: Triangulation,
segmentNumber?: number,
): { ): {
attributes: { attributes: {
[attributeName: string]: IAttribute; [attributeName: string]: IAttribute;

View File

@ -187,6 +187,7 @@ export default class StyleAttributeService implements IStyleAttributeService {
public createAttributesAndIndices( public createAttributesAndIndices(
features: IEncodeFeature[], features: IEncodeFeature[],
triangulation: Triangulation, triangulation: Triangulation,
segmentNumber: number,
): { ): {
attributes: { attributes: {
[attributeName: string]: IAttribute; [attributeName: string]: IAttribute;
@ -217,7 +218,7 @@ export default class StyleAttributeService implements IStyleAttributeService {
vertices: verticesForCurrentFeature, vertices: verticesForCurrentFeature,
normals: normalsForCurrentFeature, normals: normalsForCurrentFeature,
size: vertexSize, size: vertexSize,
} = this.triangulation(feature); } = this.triangulation(feature, segmentNumber);
indicesForCurrentFeature.forEach((i) => { indicesForCurrentFeature.forEach((i) => {
indices.push(i + verticesNum); indices.push(i + verticesNum);
}); });

View File

@ -858,6 +858,7 @@ export default class BaseLayer<ChildLayerStyleOptions = {}> extends EventEmitter
vertexShader, vertexShader,
fragmentShader, fragmentShader,
triangulation, triangulation,
segmentNumber,
...rest ...rest
} = options; } = options;
this.shaderModuleService.registerModule(moduleName, { this.shaderModuleService.registerModule(moduleName, {
@ -872,6 +873,7 @@ export default class BaseLayer<ChildLayerStyleOptions = {}> extends EventEmitter
} = this.styleAttributeService.createAttributesAndIndices( } = this.styleAttributeService.createAttributesAndIndices(
this.encodedData, this.encodedData,
triangulation, triangulation,
segmentNumber,
); );
return createModel({ return createModel({
attributes, attributes,

View File

@ -202,8 +202,11 @@ export function RasterImageTriangulation(feature: IEncodeFeature) {
* @param feature * @param feature
* @param segNum 线线 * @param segNum 线线
*/ */
export function LineArcTriangulation(feature: IEncodeFeature) { export function LineArcTriangulation(
const segNum = 30; feature: IEncodeFeature,
segmentNumber?: number,
) {
const segNum = segmentNumber ? segmentNumber : 30;
const coordinates = feature.coordinates as IPosition[]; const coordinates = feature.coordinates as IPosition[];
const positions = []; const positions = [];
const indexArray = []; const indexArray = [];

View File

@ -33,6 +33,7 @@ export default class ArcModel extends BaseModel {
forward = true, forward = true,
lineTexture = false, lineTexture = false,
iconStep = 100, iconStep = 100,
segmentNumber = 30,
} = this.layer.getLayerConfig() as ILineLayerStyleOptions; } = this.layer.getLayerConfig() as ILineLayerStyleOptions;
if (this.dataTextureTest && this.dataTextureNeedUpdate({ opacity })) { if (this.dataTextureTest && this.dataTextureNeedUpdate({ opacity })) {
@ -89,7 +90,7 @@ export default class ArcModel extends BaseModel {
u_opacity: isNumber(opacity) ? opacity : 1.0, u_opacity: isNumber(opacity) ? opacity : 1.0,
u_textureBlend: textureBlend === 'normal' ? 0.0 : 1.0, u_textureBlend: textureBlend === 'normal' ? 0.0 : 1.0,
segmentNumber: 30, segmentNumber,
u_line_type: lineStyleObj[lineType || 'solid'], u_line_type: lineStyleObj[lineType || 'solid'],
u_dash_array: dashArray, u_dash_array: dashArray,
u_blur: 0.9, u_blur: 0.9,
@ -131,6 +132,10 @@ export default class ArcModel extends BaseModel {
} }
public buildModels(): IModel[] { public buildModels(): IModel[] {
const {
segmentNumber = 30,
} = this.layer.getLayerConfig() as ILineLayerStyleOptions;
return [ return [
this.layer.buildLayerModel({ this.layer.buildLayerModel({
moduleName: 'arc2dline', moduleName: 'arc2dline',
@ -139,6 +144,7 @@ export default class ArcModel extends BaseModel {
triangulation: LineArcTriangulation, triangulation: LineArcTriangulation,
depth: { enable: false }, depth: { enable: false },
blend: this.getBlend(), blend: this.getBlend(),
segmentNumber,
}), }),
]; ];
} }

View File

@ -31,6 +31,7 @@ export default class Arc3DModel extends BaseModel {
dashArray = [10, 5], dashArray = [10, 5],
lineTexture = false, lineTexture = false,
iconStep = 100, iconStep = 100,
segmentNumber = 30,
} = this.layer.getLayerConfig() as ILineLayerStyleOptions; } = this.layer.getLayerConfig() as ILineLayerStyleOptions;
if (dashArray.length === 2) { if (dashArray.length === 2) {
@ -87,7 +88,7 @@ export default class Arc3DModel extends BaseModel {
// u_opacity: opacity === undefined ? 1 : opacity, // u_opacity: opacity === undefined ? 1 : opacity,
u_opacity: isNumber(opacity) ? opacity : 1.0, u_opacity: isNumber(opacity) ? opacity : 1.0,
u_textureBlend: textureBlend === 'normal' ? 0.0 : 1.0, u_textureBlend: textureBlend === 'normal' ? 0.0 : 1.0,
segmentNumber: 30, segmentNumber,
u_line_type: lineStyleObj[lineType as string] || 0.0, u_line_type: lineStyleObj[lineType as string] || 0.0,
u_dash_array: dashArray, u_dash_array: dashArray,

View File

@ -34,6 +34,7 @@ export default class GreatCircleModel extends BaseModel {
dashArray = [10, 5], dashArray = [10, 5],
lineTexture = false, lineTexture = false,
iconStep = 100, iconStep = 100,
segmentNumber = 30,
} = this.layer.getLayerConfig() as Partial<ILineLayerStyleOptions>; } = this.layer.getLayerConfig() as Partial<ILineLayerStyleOptions>;
// console.log('opacity', opacity) // console.log('opacity', opacity)
if (dashArray.length === 2) { if (dashArray.length === 2) {
@ -90,7 +91,7 @@ export default class GreatCircleModel extends BaseModel {
// u_opacity: opacity === undefined ? 1 : opacity, // u_opacity: opacity === undefined ? 1 : opacity,
u_opacity: isNumber(opacity) ? opacity : 1.0, u_opacity: isNumber(opacity) ? opacity : 1.0,
u_textureBlend: textureBlend === 'normal' ? 0.0 : 1.0, u_textureBlend: textureBlend === 'normal' ? 0.0 : 1.0,
segmentNumber: 30, segmentNumber,
u_line_type: lineStyleObj[lineType as string] || 0.0, u_line_type: lineStyleObj[lineType as string] || 0.0,
u_dash_array: dashArray, u_dash_array: dashArray,

View File

@ -44,8 +44,9 @@ export default class Amap2demo_arcLine extends React.Component {
.style({ .style({
opacity: 0.8, opacity: 0.8,
blur: 0.99, blur: 0.99,
lineType: 'dash', segmentNumber: 3,
dashArray: [5, 5], // lineType: 'dash',
// dashArray: [5, 5],
}); });
// .forward(false) // .forward(false)
scene.addLayer(layer); scene.addLayer(layer);