X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=blobdiff_plain;f=Primitives.lua;h=aafa7cbfa02bfc6fdb538114e76ecf154c95f98c;hb=46c1311e546ae5cefc4f596ed13476c649f12f66;hp=88a3849cd74bc3950ef506a7c7be71f38a876b0c;hpb=1a83c3fa829a87138827cd937a50f1ef210f7e0b;p=raymarcher.git diff --git a/Primitives.lua b/Primitives.lua index 88a3849..aafa7cb 100644 --- a/Primitives.lua +++ b/Primitives.lua @@ -3,14 +3,23 @@ require "Vector" local V = Vector local function make_sphere(centre, radius, texture) - return function(p) - return {dist = V.norm(p-centre) - radius, - texture = texture} - end + local norm = V.norm + return function(p) + return {dist = V.norm(p-centre) - radius, + texture = texture} + end +end + +local function make_plane(centre, normal, texture) + return function(p) + return {dist = normal*(p-centre), + texture = texture} + end end Primitives = { - make_sphere = make_sphere + make_sphere = make_sphere, + make_plane = make_plane } return Primitives