IceCreamYou/THREE.Terrain

Feature request: button to download geometry

ZachSaucier opened this issue · 1 comments

Great terrain generator! It saves me a lot of time by preventing me from needing to implement my own.

I only need a static terrain for my project so it'd be useful to have the ability to easily save to a file the positions of the generated geometry. Thankfully I can access them via the terrainScene.children[0]._bufferGeometry variable but it's kind of a pain and has too many vertices (I'm guessing you never decrease the array size, only use the parts you need for performance reasons).

copy(Array.prototype.slice.call(terrainScene.children[0].geometry._bufferGeometry.attributes.position.array.slice(0, 18432))) where 18432 is the segments * segments * 6 is kind of annoying...

Any chance of adding this functionality?

Glad you're finding the library useful!

The way I recommend to do this is described in the README: https://github.com/IceCreamYou/THREE.Terrain#exporting-and-importing

I'm not sure what you're referring to with excessive vertices - when THREE.Terrain generates a PlaneGeometry, it generates it at exactly the required size. (It is technically possible though not recommended to provide your own Mesh.)