Skip to content

Commit 808dff4

Browse files
committed
fix: 修复 fillImage 点图层图片镜像翻转问题
- 在着色器中对UV坐标进行X和Y轴翻转 - 解决图片绘制时的镜像翻转问题
1 parent 7c5fce9 commit 808dff4

4 files changed

Lines changed: 14 additions & 6 deletions

File tree

examples/demos/point/fill-image.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ export const fillImage: TestCase = async (options) => {
1212
},
1313
});
1414

15+
await scene.addImage(
16+
'car',
17+
'https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*AtZnTYIlkbwAAAAAQGAAAAgAemJ7AQ/original',
18+
);
1519
await scene.addImage(
1620
'marker',
1721
'https://gw.alipayobjects.com/mdn/antv_site/afts/img/A*BJ6cTpDcuLcAAAAAAAAAAABkARQnAQ',
@@ -23,7 +27,7 @@ export const fillImage: TestCase = async (options) => {
2327
{
2428
lng: 120,
2529
lat: 30,
26-
name: 'marker',
30+
name: 'car',
2731
},
2832
],
2933
{
@@ -35,9 +39,9 @@ export const fillImage: TestCase = async (options) => {
3539
},
3640
)
3741
.style({
38-
unit: 'meter',
42+
rotation: 0,
3943
})
40-
.shape('marker')
44+
.shape('car')
4145
.size(36);
4246

4347
const pointLayer2 = new PointLayer({ layerType: 'fillImage' })
@@ -58,10 +62,10 @@ export const fillImage: TestCase = async (options) => {
5862
},
5963
)
6064
.shape('marker')
61-
.size(36)
65+
.size(20)
6266
.active(true)
6367
.style({
64-
rotation: 90,
68+
rotation: 0,
6569
});
6670

6771
scene.addLayer(pointLayer);

examples/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@
2929
}
3030
</style>
3131
<script>
32+
window.forceWebGL = true
3233
window._AMapSecurityConfig = {
3334
securityJsCode: '290ddc4b0d33be7bc9b354bc6a4ca614',
3435
};
3536
</script>
36-
<script src="https://webapi.amap.com/maps?v=2.0&key=6f025e700cbacbb0bb866712d20bb35c"></script>
37+
<script src="https://webapi.amap.com/maps?v=2.0.5&key=6f025e700cbacbb0bb866712d20bb35c"></script>
3738
<script type="module" src="./index.tsx"></script>
3839
<div id="root"></div>
3940
</html>

packages/layers/src/point/shaders/fillImage/fillImage_vert.glsl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ out float v_opacity;
2323
void main() {
2424
vec3 extrude = a_Extrude;
2525
v_uv = (a_Extrude.xy + 1.0) / 2.0;
26+
v_uv.x = 1.0 - v_uv.x;
2627
v_uv.y = 1.0 - v_uv.y;
2728
v_Iconuv = a_Uv;
2829
v_opacity = opacity;

packages/maps/src/amap-next/map.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import { MapTheme } from './theme';
2222
const AMAP_VERSION = '2.0';
2323
const AMAP_API_KEY = 'f59bcf249433f8b05caaee19f349b3d7';
2424
const ZOOM_OFFSET = 1;
25+
// @ts-ignore 高德地图强制使用 WebGL,否则支付宝端内无法使用
26+
window.forceWebGL = true;
2527

2628
const AMapEventMapV2: Record<string, string> = {
2729
contextmenu: 'rightclick',

0 commit comments

Comments
 (0)