7

This is more of an approach question, rather than just technical question.

I have a generated sphere, broken down into hexagons as one mesh. Every hexagonal tile is a different kind of terrain, for instance, mountains, hills, ocean, planes, etc. I want to draw every terrain type in 3d as a set of several meshes, representing a corresponding terrain type.

Now the big question is how can I adjust terrain meshes to every hexagonal face in runtime, depending on terrain type, which can also change during runtime, e.g terramorphing. Also considering the hexagons aren't exactly regular or equal.

Bottom line, I need to take a mesh, representing terrain type and align it perfectly with a hexagonal face, representing a tile on a spherical map. Is it even possible in three.js? If it is, what technique should I use to achieve the wanted results?

Thanks in advance!

Images below:

  1. Maximal zoom in

    Maximal zoom in

  2. Zoomed out map

Zoomed out map

Community
  • 1
  • 1
user1617735
  • 451
  • 5
  • 16
  • So did you get it done? Your question title says texturing, in which case I think it would work straightforwardly with UVs. To put meshes there, I think that should work too .. just by placing meshes accordingly. That could get heavy though. – antont Jul 31 '15 at 14:52
  • I gave up on idea of creating all that in runtime. I'm generating terrain from a premade set of terrain meshes and align them with fields in blender. Then I create materials for all that and export to obj, then load in three.js – user1617735 Jul 31 '15 at 18:22
  • How does one create this kind of shape out of code? – Aaron Franke Oct 16 '17 at 19:09
  • @user1617735 Hi could you find any solutions about this?Also can you please share the source of generating hexagon meshes? – Majid Hojati Feb 01 '19 at 16:37

1 Answers1

4

Ran into a similar problem a few years ago. I also noticed that you have another post asking the same question

  • You can texture each hexagon uniquely assuming they are difference faces of the "Hex-Sphere" geometry just like you would do a cube to make a dice

    hexSphere = new THREE.Mesh(
    myHexSphereGeometry,
    new THREE.MultiMaterial( materials ) );
    scene.add( hexSphere );
    
  • You can texture hexagon faces by calculating its UV Map since it seems from your other post it does not have a UV.

As an approach I would do it similarly to how you would develop landscapes using perlin noise by interpolating your hex face textures together to make it seamless and just have it update onChange of the THREE.MultiMaterial. In your other post you mention importing your mesh from Blender. This is the opposite of what I would do since it can cause a malicious set of problems.

Heres an alternative option for you that I hope suits you well:

  • Create a cube (remember each of the sides are actually sets of triangle polygons)
  • Turn your cube into a sphere
  • Split all six cube faces until you have Six times the number of hexes you need
  • Create Six slices of each hexagon texture as triangles
  • Apply the textures in sets of arrays to each of the 6 faces of each pseudo hexagon essentially creating a group. This makes it much easier to calculate, texture, and tessellate with perlin noise while still having the awesomeness of fly-weights
  • Create another hexagon-sphere post-cube thingy (technical terms folks) that is transparent surrounding the texture sphere by repeating the previous steps mentioned. On this outer-sphere you will merge the vertices into new faces to be hexagons (right over-top of your previously texture hexagons) which will have pointers to its textured counterpart (an array of the triangle faces). This will be what the player actually interacts with and clicks.

Hope this was helpful.

Lee Taylor
  • 7,761
  • 16
  • 33
  • 49
Endorox
  • 99
  • 9