It uses a ray supercover algorithm adapted for 3D. To read more about the algorithm, see here.
Example:
Using raycast3D() to detect the node a player is pointing at regardless of how far away it is, and placing a MESE node on it:
Code: Select all
raycast3D(pos, dir, function(pos, nearest, function(pos, nearest, distance)
if minetest.env:get_node(pos).name ~= "air" then
env:add_node(nearest, {name="default:mese"})
return
end
end)
raycast3D(pos, dir, callback)
pos - MineTest position reference: {x=number, y=number, z=number}, where number is either an integer or a float value.
dir - Unit vector in MineTest direction format (obtainable through functions like player:get_look_dir()): {x=number, y=number, z=number}, where x * x + y * y + z * z == 1.
callback - function accepting the following parameters: pos (current node being tested), nearest (previous node being tested), and distance (distance from starting point of ray).
Download:
Link
License: AGPLv3