-
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.
fix: 解决 GeometryLayer 在不同底图上的渲染不一致情况 (#2523)
* fix: 解决 GeometryLayer 在不同底图上的渲染不一致情况 * chore: add changeset * fix: 统一地形高度 * docs: 更新文档
- Loading branch information
Showing
18 changed files
with
275 additions
and
119 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@antv/l7-layers': patch | ||
--- | ||
|
||
fix: 解决 GeometryLayer 在不同底图上的渲染不一致情况 |
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,4 @@ | ||
export { plane } from './plane'; | ||
export { rain } from './rain'; | ||
export { snow } from './snow'; | ||
export { terrain } from './terrain'; |
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,28 @@ | ||
import { GeometryLayer } from '@antv/l7'; | ||
import type { TestCase } from '../../types'; | ||
import { CaseScene } from '../../utils'; | ||
|
||
export const plane: TestCase = async (options) => { | ||
const scene = await CaseScene({ | ||
...options, | ||
mapConfig: { | ||
center: [120.1025, 30.2594], | ||
style: 'dark', | ||
zoom: 10, | ||
}, | ||
}); | ||
|
||
const layer = new GeometryLayer() | ||
.shape('plane') | ||
.style({ | ||
opacity: 0.8, | ||
width: 0.074, | ||
height: 0.061, | ||
center: [120.1025, 30.2594], | ||
}) | ||
.active(true) | ||
.color('#ff0'); | ||
scene.addLayer(layer); | ||
|
||
return scene; | ||
}; |
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,33 @@ | ||
import { GeometryLayer } from '@antv/l7'; | ||
import type { TestCase } from '../../types'; | ||
import { CaseScene } from '../../utils'; | ||
|
||
export const rain: TestCase = async (options) => { | ||
const scene = await CaseScene({ | ||
...options, | ||
mapConfig: { | ||
pitch: 90, | ||
style: 'dark', | ||
center: [120, 30], | ||
zoom: 6, | ||
}, | ||
}); | ||
|
||
const layer = new GeometryLayer() | ||
.shape('sprite') | ||
.size(10) | ||
.style({ | ||
opacity: 0.3, | ||
mapTexture: | ||
'https://gw.alipayobjects.com/mdn/rms_816329/afts/img/A*w2SFSZJp4nIAAAAAAAAAAAAAARQnAQ', // rain | ||
center: [120, 30], | ||
spriteCount: 120, | ||
spriteRadius: 10, | ||
spriteTop: 300, | ||
spriteUpdate: 10, | ||
spriteScale: 0.8, | ||
}); | ||
scene.addLayer(layer); | ||
|
||
return scene; | ||
}; |
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,31 @@ | ||
import { GeometryLayer } from '@antv/l7'; | ||
import type { TestCase } from '../../types'; | ||
import { CaseScene } from '../../utils'; | ||
|
||
export const snow: TestCase = async (options) => { | ||
const scene = await CaseScene({ | ||
...options, | ||
mapConfig: { | ||
pitch: 40, | ||
style: 'dark', | ||
center: [120, 30], | ||
zoom: 6, | ||
}, | ||
}); | ||
|
||
const layer = new GeometryLayer() | ||
.shape('sprite') | ||
.size(10) | ||
.style({ | ||
mapTexture: | ||
'https://gw.alipayobjects.com/mdn/rms_816329/afts/img/A*zLQwQKBSagYAAAAAAAAAAAAAARQnAQ', // snow | ||
center: [120, 30], | ||
spriteCount: 60, | ||
spriteRadius: 10, | ||
spriteTop: 300, | ||
spriteUpdate: 5, | ||
}); | ||
scene.addLayer(layer); | ||
|
||
return scene; | ||
}; |
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,84 @@ | ||
import { GeometryLayer } from '@antv/l7'; | ||
import type { TestCase } from '../../types'; | ||
import { CaseScene } from '../../utils'; | ||
|
||
export const terrain: TestCase = async (options) => { | ||
const scene = await CaseScene({ | ||
...options, | ||
mapConfig: { | ||
center: [120.1025, 30.2594], | ||
style: 'dark', | ||
pitch: 65, | ||
rotation: 180, | ||
zoom: 14, | ||
}, | ||
}); | ||
|
||
let currentZoom = 14, | ||
currentModelData = '100x100'; | ||
|
||
const layer = new GeometryLayer().shape('plane').style({ | ||
width: 0.074, | ||
height: 0.061, | ||
center: [120.1025, 30.2594], | ||
widthSegments: 100, | ||
heightSegments: 100, | ||
terrainClipHeight: 1, | ||
mapTexture: | ||
'https://gw.alipayobjects.com/mdn/rms_23a451/afts/img/A*gA0NRbuOF5cAAAAAAAAAAAAAARQnAQ', | ||
terrainTexture: | ||
'https://gw.alipayobjects.com/mdn/rms_23a451/afts/img/A*eYFaRYlnnOUAAAAAAAAAAAAAARQnAQ', | ||
rgb2height: (r, g, b) => { | ||
let h = (r * 255.0 * 256.0 * 256.0 + g * 255.0 * 256.0 + b * 255.0) * 0.1; | ||
h = h / 200 - 12750; | ||
h = Math.max(0, h); | ||
return h; | ||
}, | ||
}); | ||
|
||
let modelData10: any, modelData20: any, modelData100: any; | ||
|
||
layer.on('terrainImageLoaded', () => { | ||
modelData10 = layer.layerModel.createModelData({ | ||
widthSegments: 10, | ||
heightSegments: 10, | ||
}); | ||
|
||
modelData20 = layer.layerModel.createModelData({ | ||
widthSegments: 20, | ||
heightSegments: 20, | ||
}); | ||
|
||
modelData100 = layer.layerModel.createModelData({ | ||
widthSegments: 100, | ||
heightSegments: 100, | ||
}); | ||
}); | ||
|
||
scene.on('zoom', () => { | ||
const zoom = Math.floor(scene.getZoom()); | ||
if (currentZoom !== zoom) { | ||
if (zoom > 13) { | ||
if (currentModelData !== '100x100') { | ||
layer.updateModelData(modelData100); | ||
currentModelData = '100x100'; | ||
} | ||
} else if (zoom > 12) { | ||
if (currentModelData !== '20x20') { | ||
layer.updateModelData(modelData20); | ||
currentModelData = '20x20'; | ||
} | ||
} else { | ||
if (currentModelData !== '10x10') { | ||
layer.updateModelData(modelData10); | ||
currentModelData = '10x10'; | ||
} | ||
} | ||
currentZoom = zoom; | ||
} | ||
}); | ||
|
||
scene.addLayer(layer); | ||
|
||
return scene; | ||
}; |
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.