Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix regl bool uniform #2420

Merged
merged 3 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .changeset/late-plums-rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
'@antv/l7-layers': patch
'@antv/l7-component': patch
'@antv/l7-core': patch
'@antv/l7': patch
'@antv/l7-map': patch
'@antv/l7-maps': patch
'@antv/l7-renderer': patch
'@antv/l7-scene': patch
'@antv/l7-source': patch
'@antv/l7-test-utils': patch
'@antv/l7-three': patch
'@antv/l7-utils': patch
---

fix regl bool uniform
27 changes: 27 additions & 0 deletions packages/layers/__tests__/tile/raster-tile.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,31 @@ describe('raster-tile', () => {
scene.addLayer(layer1);
scene.setZoom(12);
});

it('rasterLayer rgb', async () => {
const layer = new RasterLayer()
.source(
'https://tiles{1-3}.geovisearth.com/base/v1/terrain_rgb/{z}/{x}/{y}?format=png&tmsIds=w&token=b2a0cfc132cd60b61391b9dd63c15711eadb9b38a9943e3f98160d5710aef788',
{
parser: {
type: 'rasterTile',
dataType: 'terrainRGB',
tileSize: 256,
zoomOffset: 0,
},
},
)
.style({
clampLow: false,
clampHigh: false,
domain: [0, 7000],
rampColors: {
colors: ['#d73027', '#fc8d59', '#fee08b', '#d9ef8b', '#91cf60', '#1a9850'],
positions: [0, 0.2, 0.4, 0.6, 0.8, 1.0],
},
});

scene.addLayer(layer);
scene.setZoom(12);
});
});
6 changes: 6 additions & 0 deletions packages/layers/src/core/BaseModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ export default class BaseModel<ChildLayerStyleOptions = {}> implements ILayerMod
...attributeInfo.uniformsOption,
...commoninfo.uniformsOption,
};
// 兼容 Regl Boolean 类型
Object.keys(result).forEach((key) => {
if (typeof result[key] === 'boolean') {
result[key] = result[key] ? 1 : 0;
}
});
//如果是regl渲染 需要在uniform中带上u_texture 暂时用this.rendererService.device判断
if (
!this.rendererService.hasOwnProperty('device') &&
Expand Down
13 changes: 0 additions & 13 deletions packages/layers/src/core/utils.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
export function formatUniformsOption2Std140(uniformsOption: { [key: string]: any }) {
let std140_str = '';
Object.keys(uniformsOption).forEach((key) => {
const value = uniformsOption[key];
if (Array.isArray(value)) {
std140_str += `vec${value.length} ${key};\n`;
} else {
std140_str += `flot ${key};\n`;
}
});
return std140_str;
}

export function MultipleOfFourNumber(num: number) {
return Math.max(Math.ceil(num / 4) * 4, 4);
}
Loading