-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Refactor TerrainLayer for performance and ease of use. #4275
Conversation
// eslint-disable-next-line handle-callback-err | ||
return load(terrainTile).catch(err => null); | ||
}; | ||
function getTerrain(tile) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move this to a test. As a public-facing example, I prefer to keep things simple.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you referring to the two ways this function can be used, and reducing it to the simple TileLayer usage?
That’s fair since this becomes the website example which will just show one way.
I was going to prepare an example of how I’d typically use it without TileLayer and put it somewhere too, maybe explore some fun advance usages. Any suggestions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can put the simple usage example in https://github.com/uber/deck.gl/blob/master/website/src/components/demos/layer-demos.js — these are the examples embedded in the layer docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok cool! I’ll merge this and get into geo-layers PR which can have tests and layer-demos example.
@@ -5,17 +5,29 @@ const SATELLITE = 'https://api.mapbox.com/v4/mapbox.satellite'; | |||
// Set your mapbox token here | |||
const MAPBOX_TOKEN = process.env.MapboxAccessToken; // eslint-disable-line | |||
|
|||
export const getSurface = ({x, y, z}, surface) => { | |||
export const getSurface = (surface, tile) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing here
examples/experimental/terrain/src/terrain-layer/terrain-layer.js
Outdated
Show resolved
Hide resolved
if (tile) { | ||
const {x, y, z} = tile; | ||
surfaceImage = `${STREET}/${z}/${x}/${y}.png`; | ||
} | ||
break; | ||
case 'none': | ||
default: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason <string> -> null
does not work has to do with the texture
prop is async and default to null
. The layer does not think the prop has changed. The fix will not be trivial. As an work around, you can set surfaceImage
to 0
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok - good enough for me :) thanks for looking. I’ll just add a comment to document this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, this didn't work. I'm pushing up what I tried.
I'm going to merge this and continue implementing feedback in a integration branch. |
Background
Progress on #4236
New TerrainLayer interface internalizes all data preparation logic so the user doesn't need to write that boilerplate. Also supports being used as a tiled layer (internally rendering a TileLayer of SimpleMeshLayers), or as a single mesh (internally rendering a SimpleMeshLayer).
This layer is suitable for rendering a few use cases:
Interactions while loading new tiles now feels way smoother since we're now offloading terrain mesh generation to web workers.
New prop interface:
Change List