38 lines
852 B
Lua
38 lines
852 B
Lua
|
|
local api = ...
|
||
|
|
local ecs = require("tiny-ecs")
|
||
|
|
|
||
|
|
ecs.initers = {
|
||
|
|
renderer = function()
|
||
|
|
local renderer = ecs.processingSystem()
|
||
|
|
renderer.filter = ecs.requireAll('type') -- *TODO* might need filter later
|
||
|
|
function renderer:process(obj, pass)
|
||
|
|
local type = obj:type()
|
||
|
|
if type == "Model" then
|
||
|
|
pass:setMaterial()
|
||
|
|
pass:setCullMode('none')
|
||
|
|
pass:draw(obj, 0, 0, 0, 1, 0, 1, 0, 0, 1)
|
||
|
|
end
|
||
|
|
end
|
||
|
|
ecs.addSystem( ecs.world, renderer )
|
||
|
|
end
|
||
|
|
}
|
||
|
|
|
||
|
|
ecs.enabled = true
|
||
|
|
ecs.world = ecs.world()
|
||
|
|
ecs.world.update = ecs.update -- swap with extension update-func
|
||
|
|
|
||
|
|
ecs.init = function()
|
||
|
|
ecs.initers.renderer()
|
||
|
|
end
|
||
|
|
|
||
|
|
ecs.update = function(dt)
|
||
|
|
--ecs.world.update( ecs.world, dt ) -- *TODO* different filter
|
||
|
|
end
|
||
|
|
|
||
|
|
ecs.draw = function(pass)
|
||
|
|
local opts = {
|
||
|
|
ecs.world.update( ecs.world, pass )
|
||
|
|
end
|
||
|
|
|
||
|
|
return ecs
|