I have conducted several experiments in the past to determine the most effective way to create large-scale hexagon grids.
I attempted drawing the hexagons using THREE.Line
and THREE.LineSegments
. While this method was successful for small grids, the performance took a significant hit when trying to render grids with more than 1000 cells.
As a solution, I came up with the idea of applying a texture (which contains a hexagon grid pattern) to a simple plane. By utilizing the Texture's repeat()
function, I was able to specify how many repeats would be performed vertically and horizontally.
https://i.sstatic.net/oukWQ.png
The overall performance improved drastically; however, I observed that the texture only aligned perfectly with the grid cells around the center of the plane.
https://i.sstatic.net/oFJau.png
The dots visible in the grid above represent THREE.Points, which are used to display all corners of each hexagon. This aids me in verifying if the texture matches the grid cells accurately or not.
https://i.sstatic.net/r73J2.png
Upon further inspection, I noticed that as I moved away from the center, the offset between the actual hexagon and its corresponding representation in the texture grew larger.
I believe there could be a more sophisticated approach to pre-calculate the size in order to eliminate any discrepancies between these two grids.
This serves as an example of how the grid appears and how it is generated...
window.onload = function() {
var renderer, camera, scene, controls, all_loaded = false, controls, tiles = {};
var imgDataURI = "data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAAGgAAABaCAYAAABUrhMHAAAFhklEQVR4Xu2dT2gc...
<script src="https://ajax.googleapis.com/ajax/libs/threejs/r76/three.min.js"></script>
<script src="https://dl.dropboxusercontent.com/u/3587259/Code/Threejs/OrbitControls.js"></script>