Three.js texturing terrain on a spherical hexagon grid map

半腔热情 提交于 2019-12-03 13:56:41
Endorox

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!