three-geo icon indicating copy to clipboard operation
three-geo copied to clipboard

How to make generated terrain consistently square?

Open izzymiller opened this issue 9 months ago • 3 comments

Hiya! I've been a heavy user of three-geo for a while, and overall love it— I have one thing that I've been battling against for a while and am having trouble wrapping my head around.

I realize three-geo works in tiles. I'm visualizing GPS tracks, which can sometimes cross multiple tiles. When this happens, I usually wind up with a rectangular terrain object, like this: image

What I really want is for my generated terrain to ALWAYS be perfectly square. In an ideal world, I would be able to clip the terrain to a size irrespective of tile boundaries. I realize that may be difficult, and would settle for the ability to force additional tiles to download to complete a square.

image

Any advice? Thank you!

izzymiller avatar Apr 30 '24 20:04 izzymiller

Hi, thanks for sharing this.

What I really want is for my generated terrain to ALWAYS be perfectly square. In an ideal world, I would be able to clip the terrain to a size irrespective of tile boundaries.

After reviewing code, I think, this can be done in a relatively simple way. More specifically, we can clip the generated terrain along bbox, which is guaranteed to be a square. I would like to try implementing such an algorithm, and add a new example (hopefully during this week or so).

j-devel avatar May 07 '24 13:05 j-devel

Sweet! I'm delighted to hear that.

I was able to tweak the fetch code to always return more tiles to fill in the square if there were only 2 tiles returned, but that's inefficient and has been resulting in too-large terrain that doesn't focus on my core area of focus.

I think I just don't have the three-js chops to figure out how to do that clipping. Really appreciate it and interested to see what the solution looks like.

izzymiller avatar May 07 '24 14:05 izzymiller

With clipTerrainRgb(), I managed to get geometry correct (I think). However, now I just see that texture mapping is not quite correct... So, still something remains to be done 🤔

live - https://w3reality.github.io/three-geo/examples/clip/index.html code - https://github.com/w3reality/three-geo/blob/master/examples/clip/index.html

j-devel avatar May 11 '24 11:05 j-devel