Skip to content

Commit

Permalink
fix: 修复 option 错误、shader 路径错误 (antvis#1235)
Browse files Browse the repository at this point in the history
* feat: 在点图层中去除 global 的耦合

* style: lint style

* fix: 修复更新 style 的同时更新了 option 带来的问题

* style: lint style

* feat: 拆除 arc3d 地球模式和普通模式的耦合

* style: lint style

* fix: 修复 earthExtrude shader 路径错误、option 更新错误

* style: lint style
  • Loading branch information
yiiiiiiqianyao authored Jul 14, 2022
1 parent f05073f commit aad31d3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 34 deletions.
18 changes: 12 additions & 6 deletions packages/layers/src/core/BaseLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,13 @@ export default class BaseLayer<ChildLayerStyleOptions = {}>
public updateLayerConfig(
configToUpdate: Partial<ILayerConfig | ChildLayerStyleOptions>,
) {
// 同步 rawConfig
Object.keys(configToUpdate).map((key) => {
if (key in this.rawConfig) {
// @ts-ignore
this.rawConfig[key] = configToUpdate[key];
}
});
if (!this.inited) {
this.needUpdateConfig = {
...this.needUpdateConfig,
Expand Down Expand Up @@ -635,13 +642,12 @@ export default class BaseLayer<ChildLayerStyleOptions = {}>
);
}

// this.rawConfig = {
// ...this.rawConfig,
// ...rest,
// };
this.rawConfig = {
...this.rawConfig,
...rest,
};
if (this.container) {
// this.updateLayerConfig(this.rawConfig);
this.updateLayerConfig(rest);
this.updateLayerConfig(this.rawConfig);
this.styleNeedUpdate = true;
}

Expand Down
21 changes: 7 additions & 14 deletions packages/layers/src/point/models/earthExtrude.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import { IPointLayerStyleOptions } from '../../core/interface';
import { PointExtrudeTriangulation } from '../../core/triangulation';
import { lglt2xyz } from '../../earth/utils';
import { calculateCentroid } from '../../utils/geo';
import pointExtrudeFrag from '../shaders/earth/extrude/extrude_frag.glsl';
import pointExtrudeVert from '../shaders/earth/extrude/extrude_vert.glsl';
import pointExtrudeFrag from '../shaders/earth/extrude_frag.glsl';
import pointExtrudeVert from '../shaders/earth/extrude_vert.glsl';

export default class ExtrudeModel extends BaseModel {
private raiseCount: number = 0;
Expand Down Expand Up @@ -162,8 +162,6 @@ export default class ExtrudeModel extends BaseModel {
this.dataTexture?.destroy();
}
protected registerBuiltinAttributes() {
// TODO: 判断当前的点图层的模型是普通地图模式还是地球模式
const isGlobel = this.mapService.version === 'GLOBEL';
// point layer size;
this.styleAttributeService.registerStyleAttribute({
name: 'size',
Expand Down Expand Up @@ -239,16 +237,11 @@ export default class ExtrudeModel extends BaseModel {
size: 3,
update: (feature: IEncodeFeature, featureIdx: number) => {
const coordinates = calculateCentroid(feature.coordinates);
if (isGlobel) {
// TODO: 在地球模式下需要将传入 shader 的经纬度转化成对应的 xyz 坐标
return lglt2xyz([coordinates[0], coordinates[1]]) as [
number,
number,
number,
];
} else {
return [coordinates[0], coordinates[1], 0];
}
return lglt2xyz([coordinates[0], coordinates[1]]) as [
number,
number,
number,
];
},
},
});
Expand Down
15 changes: 1 addition & 14 deletions packages/layers/src/point/models/extrude.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { isNumber } from 'lodash';
import BaseModel from '../../core/BaseModel';
import { IPointLayerStyleOptions } from '../../core/interface';
import { PointExtrudeTriangulation } from '../../core/triangulation';
import { lglt2xyz } from '../../earth/utils';
import { calculateCentroid } from '../../utils/geo';
import pointExtrudeFrag from '../shaders/extrude/extrude_frag.glsl';
import pointExtrudeVert from '../shaders/extrude/extrude_vert.glsl';
Expand Down Expand Up @@ -103,7 +102,6 @@ export default class ExtrudeModel extends BaseModel {
}
}
}

return {
// 圆柱体的拾取高亮是否要计算光照
u_pickLight: Number(pickLight),
Expand Down Expand Up @@ -162,8 +160,6 @@ export default class ExtrudeModel extends BaseModel {
this.dataTexture?.destroy();
}
protected registerBuiltinAttributes() {
// TODO: 判断当前的点图层的模型是普通地图模式还是地球模式
const isGlobel = this.mapService.version === 'GLOBEL';
// point layer size;
this.styleAttributeService.registerStyleAttribute({
name: 'size',
Expand Down Expand Up @@ -239,16 +235,7 @@ export default class ExtrudeModel extends BaseModel {
size: 3,
update: (feature: IEncodeFeature, featureIdx: number) => {
const coordinates = calculateCentroid(feature.coordinates);
if (isGlobel) {
// TODO: 在地球模式下需要将传入 shader 的经纬度转化成对应的 xyz 坐标
return lglt2xyz([coordinates[0], coordinates[1]]) as [
number,
number,
number,
];
} else {
return [coordinates[0], coordinates[1], 0];
}
return [coordinates[0], coordinates[1], 0];
},
},
});
Expand Down

0 comments on commit aad31d3

Please sign in to comment.