caewok / fvtt-elevated-vision

Adjust Foundry VTT vision, lighting, and token elevations based on terrain, wall, or token elevation.
MIT License
12 stars 5 forks source link

Feature request: heightmap provider override #100

Closed OmegaRogue closed 6 months ago

OmegaRogue commented 7 months ago

I want to make maps with 3d terrain on multiple layers, which currently isnt possible with elevated vision and levels. It would be very useful if elevated vision allowed setting a function that is called with xyz coordinates as the parameter that returns the elevation of the nearest floor at that point:

function getFloorHeight(x: number, y: number, z: number): number)
caewok commented 6 months ago

If I understand you correctly, I think you can already do this:

// For this example, assume the token is above an overhead tile and the tile is set to elevation 20.
pt = _token.center;
pt.z = CONFIG.GeometryLib.utils.gridUnitsToPixels(30); // Set the point to elevation 30, using grid units consistent with x,y.
canvas.elevation.CoordinateElevationCalculator.groundElevationAt(pt); // Should return 20, which is the nearest floor: the tile at 20. 

// If you wanted the terrain elevation:
canvas.elevation.CoordinateElevationCalculator.terrainElevationAt(pt); // 0 unless you set the terrain elevation to something else.

canvas.elevation.CoordinateElevationCalculator.groundElevationAt should account for multiple overhead tiles as well as the terrain elevation. Given a point in space, it will return the highest elevation of the objects below that point.