-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLight.lua
38 lines (28 loc) · 832 Bytes
/
Light.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
local class = require 'middleclass'
local Vec = require 'core/Vector'
local Light = require 'core/graphics/Light'
local TypeNameToId =
{
ambient = 0,
directional = 1,
sphere = 2,
tube = 3,
spot = 4
}
local PbrLight = class(here('Light'), Light)
function PbrLight:initialize()
Light.initialize(self)
end
function PbrLight:_setShaderLightType( typeName )
self.shaderVariables:set('LightType', TypeNameToId[typeName], 'int')
end
function PbrLight:setValue( value )
assert(Vec:isInstance(value) and #value == 3, 'Must be a 3D vector.')
self.shaderVariables:set('LightValue', value)
Light.setValue(self, value:length())
end
function PbrLight:setRange( range )
Light.setRange(self, range)
self.shaderVariables:set('LightRange', range)
end
return PbrLight