Terrain and position on one tile

Hi. I have a simple grid 64x64 exported from Blender. Then I’m using the technique from the TerrainGrid to display a terrain based on an alpha map and tile textures. Everything is working as expected. But now I need to place objects on the map based on the tile coordinates. For example, top left tile is 0,0 and bottom right tile is 63,63 and I try to place an object on tile 39,29. For that I have figured out a system that gives me the vertex position for each tile coordinate. For example the tile 39,29 have the vertex (-8.63492,-2.53968,0) and I can place the object in the grid at those local coordinates.

This works perfect in the center of the grid but the local coordinates are slightly off for tiles that are not in the center. I checked everything in wireframe mode and it fits perfectly. Please see the attached screenshots.

I have done no transformations on the grid and nothing special at all. Each tile is 103x103 pixels on the zoom everywhere. Each vertex is exactly 1.0158 away from the other in x and y axis. All of the textures are 128x128 big.

I expect the white box to be always in the bottom right corner of the tile. Why is it slightly off to the right?

Not much code, because it’s just retrieving the vertex and place the white box there.

grid-tile-1 grid-tile-2 grid-tile-wireframe-1 grid-tile-wireframe-2

if the white box you are placing is a 3d geometry (like a Box Mesh), it’s local origin will be the 3d center of the box, as Boxes are created using extents from center. (as opposed to the 2d texture, which has it’s local origin at the corner) You may not see it from a top-down view, but the box is likely sunken halfway below the plane of your grid as well.
If this is the case, you will need to place to box at the calculated 3d world coordinates MINUS an offset of the Box’s extents in each dimension.