-
Notifications
You must be signed in to change notification settings - Fork 636
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
支持 Raster Layer 在 WebGPU 下的渲染 (#2262)
* fix: raster layer in WebGPU * fix: raster rgb layer * fix: extend 3 channels to 4 in WebGPU * chore: remove taobao npm registry
- Loading branch information
Showing
39 changed files
with
500 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
@ali:registry=https://registry.npm.alibaba-inc.com | ||
@alipay:registry=https://registry.npm.alibaba-inc.com | ||
@alife:registry=https://registry.npm.alibaba-inc.com | ||
|
||
registry=https://registry.npm.taobao.org/ | ||
@alife:registry=https://registry.npm.alibaba-inc.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,51 @@ | ||
import { Scene, PolygonLayer, LineLayer } from '@antv/l7'; | ||
import { LineLayer, PolygonLayer, Scene } from '@antv/l7'; | ||
import * as allMap from '@antv/l7-maps'; | ||
|
||
export function MapRender(option: { | ||
map: string | ||
renderer: 'regl' | 'device' | ||
map: string; | ||
renderer: 'regl' | 'device'; | ||
}) { | ||
const scene = new Scene({ | ||
id: 'map', | ||
// renderer: option.renderer === 'device' ? 'device' : 'regl', | ||
map: new allMap[option.map || 'Map']({ | ||
style: 'light', | ||
center: [ -96, 37.8 ], | ||
zoom: 3 | ||
const scene = new Scene({ | ||
id: 'map', | ||
// renderer: option.renderer, | ||
map: new allMap[option.map || 'Map']({ | ||
style: 'light', | ||
center: [-96, 37.8], | ||
zoom: 3, | ||
}), | ||
}); | ||
scene.on('loaded', () => { | ||
fetch( | ||
// 'https://gw.alipayobjects.com/os/basement_prod/d36ad90e-3902-4742-b8a2-d93f7e5dafa2.json' | ||
'https://mdn.alipayobjects.com/afts/file/A*CFbnRqXpg8wAAAAAAAAAAAAADrd2AQ/test.json', | ||
) | ||
.then((res) => res.json()) | ||
.then((data) => { | ||
console.log(data); | ||
const layer = new PolygonLayer({ autoFit: true }) | ||
.source(data) | ||
.color('#f00') | ||
.shape('fill') | ||
.active(true); | ||
const layer2 = new LineLayer({ | ||
zIndex: 2, | ||
}) | ||
}); | ||
scene.on('loaded', () => { | ||
fetch( | ||
// 'https://gw.alipayobjects.com/os/basement_prod/d36ad90e-3902-4742-b8a2-d93f7e5dafa2.json' | ||
'https://mdn.alipayobjects.com/afts/file/A*CFbnRqXpg8wAAAAAAAAAAAAADrd2AQ/test.json' | ||
) | ||
.then(res => res.json()) | ||
.then(data => { | ||
console.log(data) | ||
const layer = new PolygonLayer({ autoFit: true }) | ||
.source(data) | ||
.color("#f00") | ||
.shape("fill") | ||
.active(true); | ||
const layer2 = new LineLayer({ | ||
zIndex: 2, | ||
}) | ||
.source(data) | ||
.color("#ffffff") | ||
.active(true) | ||
.size(1) | ||
.style({ | ||
lineType: "dash", | ||
dashArray: [2, 2], | ||
}); | ||
scene.addLayer(layer); | ||
scene.addLayer(layer2); | ||
|
||
setTimeout(() => { | ||
layer.color("#f0f"); | ||
layer2.color("#00f"); | ||
scene.render(); | ||
}, 1000); | ||
|
||
|
||
}); | ||
}); | ||
.source(data) | ||
.color('#ffffff') | ||
.active(true) | ||
.size(1) | ||
.style({ | ||
lineType: 'dash', | ||
dashArray: [2, 2], | ||
}); | ||
scene.addLayer(layer); | ||
scene.addLayer(layer2); | ||
|
||
setTimeout(() => { | ||
layer.color('#f0f'); | ||
layer2.color('#00f'); | ||
scene.render(); | ||
}, 1000); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { MapRender as image } from './normal'; | ||
export { MapRender as rgb } from './rgb' | ||
export { MapRender as vector } from './vector' | ||
export { MapRender as image } from './normal'; | ||
export { MapRender as perf } from './perf'; | ||
export { MapRender as rgb } from './rgb'; | ||
export { MapRender as vector } from './vector'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { LineLayer, PolygonLayer, Scene, Source } from '@antv/l7'; | ||
// @ts-ignore | ||
import * as allMap from '@antv/l7-maps'; | ||
import { Protocol } from 'pmtiles'; | ||
const protocol = new Protocol(); | ||
Scene.addProtocol('pmtiles', protocol.tile); | ||
|
||
export function MapRender(option: { | ||
map: string; | ||
renderer: 'regl' | 'device'; | ||
}) { | ||
const scene = new Scene({ | ||
id: 'map', | ||
renderer: option.renderer, | ||
map: new allMap[option.map || 'Map']({ | ||
zoom: 4.5, | ||
center: [116.412427, 39.303573], | ||
}), | ||
}); | ||
|
||
const url = | ||
'https://mvt.amap.com/district/CHN3/{z}/{x}/{y}/4096?key=309f07ac6bc48160e80b480ae511e1e9&version='; | ||
const source = new Source(url, { | ||
parser: { | ||
type: 'mvt', | ||
tileSize: 256, | ||
warp: false, | ||
}, | ||
}); | ||
|
||
scene.on('loaded', () => { | ||
const colors = {}; | ||
const getColorByAdcode = function (adcode) { | ||
if (!colors[adcode]) { | ||
const gb = Math.floor(Math.random() * 155 + 50); | ||
colors[adcode] = 'rgb(' + gb + ',' + gb + ',255)'; | ||
} | ||
|
||
return colors[adcode]; | ||
}; | ||
// 绿地 | ||
const fill = new PolygonLayer({ | ||
sourceLayer: 'CHN_Districts', | ||
}) | ||
.source(source) | ||
.shape('fill') | ||
.color('adcode', getColorByAdcode); | ||
|
||
const line = new LineLayer({ | ||
sourceLayer: 'CHN_Districts_L', | ||
}) | ||
.source(source) | ||
.shape('simple') | ||
.color('#fee0d2'); | ||
|
||
const line2 = new LineLayer({ | ||
sourceLayer: 'CHN_Citys_L', | ||
}) | ||
.source(source) | ||
.shape('line') | ||
.size(0.6) | ||
.color('#fc9272'); | ||
|
||
const line3 = new LineLayer({ | ||
sourceLayer: 'CHN_Provinces_L', | ||
}) | ||
.source(source) | ||
.shape('line') | ||
.size(0.6) | ||
.color('#de2d26'); | ||
|
||
scene.addLayer(fill); | ||
scene.addLayer(line); | ||
scene.addLayer(line2); | ||
scene.addLayer(line3); | ||
// scene.addLayer(line2); | ||
// const debugerLayer = new TileDebugLayer({ usage: 'basemap' }); | ||
// scene.addLayer(debugerLayer); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.