-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Fix sampleTerrain when using ArcGIS Terrain #9286
Fix sampleTerrain when using ArcGIS Terrain #9286
Conversation
* fixed the doc for `TerrainData.createMesh` (missing param) * exposed `_tileAvailability` on ArcGISTiledElevationTerrainProvider as the `availability`; this fixes sampleTerrainMostDetailed which requires that property. * made `sampleTerrain` call `createMesh` on every tile requested; this fixes ArcGIS terrain which currently requires the mesh to be built before interpolating height (because the request buffer is still encoded in LERC and the decoding happens during mesh building)
* increased the active task limit for now as it was getting in the way
Thank you so much for the pull request @DanielLeone! I noticed this is your first pull request and I wanted to say welcome to the Cesium community! The Pull Request Guidelines is a handy reference for making sure your PR gets accepted quickly, so make sure to skim that.
Reviewers, don't forget to make sure that:
|
@@ -650,6 +657,7 @@ function requestAvailability(that, level, x, y) { | |||
|
|||
// Mark whole area as having availability loaded | |||
that._tilesAvailablityLoaded.addAvailableTileRange( | |||
level, |
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.
I just saw this - it looked like a missing parameter - I've got no tests or further context on this one! 😛 Will revert later.
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.
😮
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.
this makes me question _tilesAvailablityLoaded
even more...
Source/Core/sampleTerrain.js
Outdated
// Make sure to generate our mesh for each tile first | ||
// because some tiles actually require the mesh to interpolate heights | ||
// (eg: ArcGISTiledElevationTerrainProvider) | ||
.then(createMeshCreatorFunction(tileRequest)) |
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.
This is essentially the fix I've added. Call createMesh
on each tile as it comes back. However; as mentioned, this causes CWT terrain interpolateHeight
to return undefined - I haven't figured out why yet :)
Source/Core/HeightmapTerrainData.js
Outdated
@@ -182,7 +182,7 @@ Object.defineProperties(HeightmapTerrainData.prototype, { | |||
}, | |||
}); | |||
|
|||
var taskProcessor = new TaskProcessor("createVerticesFromHeightmap"); | |||
var taskProcessor = new TaskProcessor("createVerticesFromHeightmap", 5000); |
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.
Ahhh this previous limit of 5 was interfering with tests or the sand castle or something... I can't really remember 😛 I guess because every tile now has to go across the worker (during createMesh
), there's a lot more traffic, and therefore chances for that limit of 5 to be reached pretty quick. Will revert / figure it out later.
); | ||
} | ||
//>>includeEnd('debug'); | ||
return this._tilesAvailable; |
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.
This was the other fix mentioned... I'm not really across how the TileAvailability
class works and if this _tilesAvailable
property is setup correctly. I did notice there's actually two properties _tilesAvailablityLoaded
and _tilesAvailable
in the ArcGIS Terrain Provider; not sure which one is correct in this case.
Either way, I think this makes sampleTerrainMostDetailed
work as expected 👍
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.
yeah, this seems like the right thing to return. I'm still wrapping my head around _tilesAvailablityLoaded
. I think it only says whether availability has been loaded for tiles, not whether a tile is actually available. Not sure why _tilesAvailable
can't do take care of this, but there's probably a good reason.
@IanLilleyT You might be interested in this one as #8481 is next on the chopping block 😄 |
…teMesh * added some unit tests to sample terrain to test both code paths (ArcGIS and CWT) * added a bunch of test-data files so it doesn't have to hit a real terrain sever
* maybe fixed eslint
I looked over the code and the PR write-up helped get me up to speed quickly. I came to a pretty similar conclusion to you, and here's my summary (just to make sure I have all the details right): Your idea of creating a new I'm tempted to remove custom encodings from |
I was thinking about this a little more and started to change my mind from my previous comment. If a So I'm liking the original approach of calling |
…is the mesh is not created and the encoding is LERC. * sampleTerrain will now call createMesh if interpolateHeight first returns undefined.
@IanLilleyT Sounds good to me. Code has been updated! 👍 Let me know and I'll revert some of those other temporary changes. |
… it returns a promise; working around the fact you can only schedule 5 meshes to be created at once.
Okay, one more change. I reverted the 5000 limit on the task processor - so we're back to 5 as in master. |
Nice My two issues right now are:
Anyway, feel free to start removing any of the temp code. Once my PR is merged we can do code review. Thanks! |
Okay no worries. Please let me know when the |
@DanielLeone, I opened #9313. Once you have a chance to merge with that branch please set this PR's base branch to Let me know if you have any questions! |
…to fix-arcgis-sample-terrain-height # Conflicts: # Source/Core/TerrainData.js
* shuffled and reduced the size of the test data * bulked out the test assertions a little
@IanLilleyT Done! I got it down to |
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.
@DanielLeone Overall this looks really good. In the end not a lot of code changed which I love to see! I tried it out with the Terrain.html
you had in a previous commit and everything is working as expected. There's several little comments, mostly for the specs which need to be ES5 instead of ES6.
Also, please add an entry to the Fixes
section for the Feburary release in CHANGES.md
(the Fixes
section doesn't exist yet but it will be underneath the Additions
section. I made a mistake with the order in terrainDataThrottleControl
branch so you'll have to merge first).
…to fix-arcgis-sample-terrain-height
* moved the test data files around * added a line to CHANGES.md
@IanLilleyT thanks for all the suggestions 👍 I think I got them all 🌮 |
Specs/Core/sampleTerrainSpec.js
Outdated
sourceUrl.pathname + sourceUrl.search + sourceUrl.hash; | ||
// find a key (source path) path in the spec which matches (ends with) the requested url | ||
var availablePaths = Object.keys(proxySpec); | ||
var proxiedUrl = null; |
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.
Do var proxiedUrl;
and down below if (!defined(proxiedUrl)) {
(will need to include defined.js
). That's the more standard way of handling null/undefined in the repo.
@DanielLeone I posted one last code request If all goes well #9313 and this will be in the February release! |
@IanLilleyT Thanks for writing the throttling code and the quick PR reviews! 👍 🌮 |
Unfortunately didn't get #9313 reviewed in time for the February release, so it will be out in the March release. |
Merged at last! Thanks @DanielLeone! |
Now time to peek at #9389 |
Hi all,
I've got a WIP fix an issue and I'm keen for some feedback/suggestions.
This PR fixes #8007
There's 2 bugs as mentioned in the issue.
The
availability
property was not exposed from theArcGISTiledElevationTerrainProvider
._tilesAvailable
calling
interpolateHeight
on aHeightmapTerrainData
instance fromArcGISTiledElevationTerrainProvider
will return undefined.interpolateHeight
method ofHeightmapTerrainData
will try to use that array buffer (returned from the server) directly like a 2D height map array lookup thing.createMesh()
before callinginterpolateHeight
createVerticiesFromHeightmap
(which is whatcreateMesh
calls) is where the LERC decoding happens.interpolateHeight
rather than the LERC buffer. This code path works as expected.I've opted for this solution (just calling
createMesh
on every tile) insidesampleTerrain
as it seemed to be the lowest friction change to me; but I don't think it's an optimal solution.Another maybe better idea:
HeightmapTerrainData
class which already has it's mesh created beforehand; and then to meet the TerrainData interfacecreateMesh
would just be a no-op; andupsample
seems to use the mesh anyway to build a new height map buffer. SoMeshedHeightmapTerrainData.upsample -> HeightmapTerrainData
or something.Current issue with this solution:
sampleTerrain
unit tests are failing and I'm not sure why. It appears when using Cesium World Terrain (as in the unit tests);interpolateHeight
via the mesh code path isn't working for some reason 😢 . Any ideas on this one? I couldn't find any unit tests coveringQuantizedMeshTerrainData.interpolateHeight
when using the mesh code; nor do I see where it's ever really run in production (until now in this PR)... any help here is appreciated.A less-than-ideal solution to this new issue would be
createMesh
for ArcGIS tiles.Other changes:
TerrainData.createMesh
(it was missing the terrain exaggeration param)sampleTerrain
andsampleTerrainMostDetailed
respectively and a few other changes - this is just temporary while testing though.Any help is much appreciated; thanks!