From 94005675e960de8a08922573317a964431bf4810 Mon Sep 17 00:00:00 2001 From: Max Cahill <1bardesign@gmail.com> Date: Wed, 26 Feb 2020 15:25:02 +1100 Subject: [PATCH] [fixed] vec3:new - seldom used but still important --- vec3.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/vec3.lua b/vec3.lua index 2a618cd..f66de1e 100644 --- a/vec3.lua +++ b/vec3.lua @@ -25,15 +25,17 @@ vec3.type = "vec3" --probably-too-flexible ctor function vec3:new(x, y, z) - if x and y then + if x and y and z then return vec3:xyz(x, y, z) elseif x then if type(x) == "number" then return vec3:filled(x) - elseif x.type == "vec3" then - return x:copy() - elseif type(x) == "table" and x[1] and x[2] and x[3] then - return vec3:xyz(x[1], x[2], x[3]) + elseif type(x) == "table" then + if x.type == "vec3" then + return x:copy() + elseif x[1] and x[2] and x[3] then + return vec3:xyz(x[1], x[2], x[3]) + end end end return vec3:zero()