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

支持 Mask 在 WebGPU 下的渲染 #2192

Merged
merged 3 commits into from
Dec 21, 2023
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
Binary file added __tests__/e2e/snapshots/mask-single-mask.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 2 additions & 4 deletions __tests__/e2e/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ export const tests = {
'point-normal-device': 'features/point/point-normal-device',
'citybuilding-amap1': 'features/citybuilding/amap1',
'line-arc-plane': 'features/line/line-arc-plane',
'mask-single-mask': 'features/mask/single-mask',
};

export const testList = [
'PointFill',
'PointImage'
]
export const testList = ['PointFill', 'PointImage'];
47 changes: 22 additions & 25 deletions dev-demos/features/mask/demos/heatmap.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// @ts-ignore
import { Scene, HeatmapLayer, PolygonLayer } from '@antv/l7';
import { HeatmapLayer, PolygonLayer, Scene } from '@antv/l7';
// @ts-ignore
import { GaodeMap } from '@antv/l7-maps';
import { GaodeMap, Map } from '@antv/l7-maps';
import React, { useEffect } from 'react';

export default () => {
useEffect(() => {
const scene = new Scene({
id: 'map',

map: new GaodeMap({
renderer: process.env.renderer,
map: new (process.env.CI ? Map : GaodeMap)({
center: [120.165, 30.26],
pitch: 0,
zoom: 2,
Expand Down Expand Up @@ -49,20 +49,20 @@ export default () => {
],
};


scene.on('loaded', () => {


fetch(
'https://gw.alipayobjects.com/os/basement_prod/d3564b06-670f-46ea-8edb-842f7010a7c6.json',
)
.then((res) => res.json())
.then((data) => {
const polygonLayer = new PolygonLayer({visible:true}).source(maskData).shape('fill').color('#f00').style({opacity:0.4});
const polygonLayer = new PolygonLayer({ visible: true })
.source(maskData)
.shape('fill')
.color('#f00')
.style({ opacity: 0.4 });
const heatmapLayer = new HeatmapLayer({
maskLayers: [polygonLayer],
mask:false,

// mask: false,
})
.source(data)
.shape('heatmap') // heatmap3D heatmap
Expand All @@ -83,23 +83,20 @@ export default () => {
positions: [0, 0.2, 0.4, 0.6, 0.8, 1.0],
},
});
scene.addLayer(polygonLayer);
scene.addLayer(heatmapLayer);

setTimeout(()=>{
console.log('add mask');
// heatmapLayer.addMask(polygonLayer);
// scene.render();

console.log('disable mask');
// heatmapLayer.disableMask();
// scene.render();
heatmapLayer.enableMask();
scene.render();
scene.addLayer(polygonLayer);
scene.addLayer(heatmapLayer);

// setTimeout(() => {
// console.log('add mask');
// // heatmapLayer.addMask(polygonLayer);
// // scene.render();

},2000)

// console.log('disable mask');
// // heatmapLayer.disableMask();
// // scene.render();
// heatmapLayer.enableMask();
// scene.render();
// }, 2000);
});
});
}, []);
Expand Down
8 changes: 4 additions & 4 deletions dev-demos/features/mask/demos/heatmapgrid.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// @ts-ignore
import { Scene, HeatmapLayer } from '@antv/l7';
import { HeatmapLayer, Scene } from '@antv/l7';
// @ts-ignore
import { GaodeMap } from '@antv/l7-maps';
import { GaodeMap, Map } from '@antv/l7-maps';
import React, { useEffect } from 'react';

export default () => {
useEffect(() => {
const scene = new Scene({
id: 'map',

map: new GaodeMap({
// renderer: process.env.renderer,
map: new (process.env.CI ? Map : GaodeMap)({
center: [120.165, 30.26],
pitch: 0,
zoom: 2,
Expand Down
8 changes: 4 additions & 4 deletions dev-demos/features/mask/demos/heatmapgrid3d.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// @ts-ignore
import { Scene, HeatmapLayer } from '@antv/l7';
import { HeatmapLayer, Scene } from '@antv/l7';
// @ts-ignore
import { GaodeMap } from '@antv/l7-maps';
import { GaodeMap, Map } from '@antv/l7-maps';
import React, { useEffect } from 'react';

export default () => {
useEffect(() => {
const scene = new Scene({
id: 'map',

map: new GaodeMap({
renderer: process.env.renderer,
map: new (process.env.CI ? Map : GaodeMap)({
style: 'light',
pitch: 56.499,
center: [114.07737552216226, 22.542656745583486],
Expand Down
17 changes: 10 additions & 7 deletions dev-demos/features/mask/demos/hexgon.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// @ts-ignore
import { Scene, HeatmapLayer,PolygonLayer } from '@antv/l7';
import { HeatmapLayer, PolygonLayer, Scene } from '@antv/l7';
// @ts-ignore
import { GaodeMap } from '@antv/l7-maps';
import { GaodeMap, Map } from '@antv/l7-maps';
import React, { useEffect } from 'react';

export default () => {
useEffect(() => {
const scene = new Scene({
id: 'map',

map: new GaodeMap({
renderer: process.env.renderer,
map: new (process.env.CI ? Map : GaodeMap)({
center: [120.165, 30.26],
pitch: 0,
zoom: 6,
Expand Down Expand Up @@ -54,10 +54,13 @@ export default () => {
)
.then((res) => res.text())
.then((data) => {
const polygonLayer = new PolygonLayer().source(maskData).shape('fill').color('#f00').style({opacity:0.5});
const polygonLayer = new PolygonLayer()
.source(maskData)
.shape('fill')
.color('#f00')
.style({ opacity: 0.5 });
const layer = new HeatmapLayer({
maskLayers: [polygonLayer]

maskLayers: [polygonLayer],
})
.source(data, {
parser: {
Expand Down
20 changes: 11 additions & 9 deletions dev-demos/features/mask/demos/image.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// @ts-ignore
import { Scene, ImageLayer,PolygonLayer } from '@antv/l7';
import { ImageLayer, PolygonLayer, Scene } from '@antv/l7';
// @ts-ignore
import { GaodeMap } from '@antv/l7-maps';
import { GaodeMap, Map } from '@antv/l7-maps';
import React, { useEffect } from 'react';

export default () => {
useEffect(() => {
const scene = new Scene({
id: 'map',

map: new GaodeMap({
renderer: process.env.renderer,
map: new (process.env.CI ? Map : GaodeMap)({
center: [120.165, 30.26],
pitch: 0,
zoom: 15,
Expand Down Expand Up @@ -51,19 +51,21 @@ export default () => {
};

scene.on('loaded', () => {
const polygonLayer = new PolygonLayer().source(maskData).shape('fill').color('#f00').style({opacity:0.5});
const polygonLayer = new PolygonLayer()
.source(maskData)
.shape('fill')
.color('#f00')
.style({ opacity: 0.5 });
const layer = new ImageLayer({
maskLayers:[polygonLayer],
maskLayers: [polygonLayer],
});
layer.source(
'https://gw.alipayobjects.com/mdn/rms_816329/afts/img/A*4UApTKmeiy4AAAAAAAAAAAAAARQnAQ',
{
parser: {
type: 'image',
extent: [
120.14802932739258,
30.262773970881057,
120.17669677734374,
120.14802932739258, 30.262773970881057, 120.17669677734374,
30.25239466884559,
],
},
Expand Down
27 changes: 14 additions & 13 deletions dev-demos/features/mask/demos/raster.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-ignore
import { Scene, RasterLayer,PolygonLayer } from '@antv/l7';
import { PolygonLayer, RasterLayer, Scene } from '@antv/l7';
// @ts-ignore
import { GaodeMap } from '@antv/l7-maps';
import { GaodeMap, Map } from '@antv/l7-maps';
import React, { useEffect } from 'react';

import * as GeoTIFF from 'geotiff';
Expand All @@ -28,11 +28,11 @@ async function getTiffData() {

export default () => {
// @ts-ignore
useEffect( async () => {
useEffect(async () => {
const scene = new Scene({
id: 'map',

map: new GaodeMap({
renderer: process.env.renderer,
map: new (process.env.CI ? Map : GaodeMap)({
center: [120.165, 30.26],
pitch: 0,
zoom: 2,
Expand All @@ -52,11 +52,15 @@ export default () => {
.then((res) => res.json())
.then((maskData) => {
const polygonLayer = new PolygonLayer({
visible:false
}).source(maskData).shape('fill').color('#f00').style({opacity:0.5});
visible: false,
})
.source(maskData)
.shape('fill')
.color('#f00')
.style({ opacity: 0.5 });
const layer = new RasterLayer({
maskLayers: [polygonLayer]
});
maskLayers: [polygonLayer],
});
const mindata = -0;
const maxdata = 8000;
layer
Expand All @@ -66,10 +70,7 @@ export default () => {
width: tiffdata.width,
height: tiffdata.height,
extent: [
73.482190241,
3.82501784112,
135.106618732,
57.6300459963,
73.482190241, 3.82501784112, 135.106618732, 57.6300459963,
],
},
})
Expand Down
Loading
Loading