IceCreamYou / THREE.Terrain

A procedural terrain generation engine for use with the Three.js 3D graphics library for the web.
https://icecreamyou.github.io/THREE.Terrain/
MIT License
706 stars 109 forks source link

Feature request: button to download geometry #19

Closed ZachSaucier closed 5 years ago

ZachSaucier commented 5 years ago

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?

IceCreamYou commented 5 years ago

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.)