20 lines
494 B
Lua
20 lines
494 B
Lua
local function normal( a, b, c )
|
|
local norm = a*a+b*b+c*c
|
|
if norm < 0.0001 then return p end
|
|
norm = 1.0 / math.sqrt( norm )
|
|
return norm *a, norm *b, norm *c
|
|
end
|
|
|
|
local light = {}
|
|
light[1], light[2], light[3] = normal( 1.0, 1.0, 0.0 ) --direction TO the light btw
|
|
light.target = 1
|
|
|
|
local c, s, p = math.cos, math.sin, 2*math.pi
|
|
function light.setTarget( i )
|
|
light.target = light.target + 1
|
|
i = i - 1
|
|
light[1], light[2], light[3] = normal( c(i*p/7), 1, s(i*p/7) )
|
|
end
|
|
|
|
|
|
return light |