How can i add collision detection in a voxel terrain

I don’t know the Minecraft example but i guess the voxel data is stored in a 3D array, you can use this to compute a distance field to the surface, finding from your position the voxel index in the array and check the distance with the surrounding 27 voxels for example which would be quite cheap since it’s static and doesn’t need interpolation, each non-surface voxel can be skipped right away.

But to collide with the actual blocky block surface and not the smooth distance field you need to use the plain distance to the block.

Edit: i see it uses a Uint8Array so the original distance field noise isn’t involved anyway. Just check which blocks around you are solid and if, get the distance from your player to it’s surface, doing this with all 27 blocks and always take the shortest distance like before testing the next shortestDistance = Math.min( shortestDistance, distance );