package.path=package.path..";C:\\Users\\micro\\AppData\\Roaming\\com.nesbox.tic\\TIC-80\\rift\\?.lua"	-- jtruk
package.path=package.path..";C:\\Users\\Ronan\\AppData\\Roaming\\com.nesbox.tic\\TIC-80\\rift\\?.lua"	-- Mantratronic
package.path=package.path..";C:\\Users\\matt\\AppData\\Roaming\\com.nesbox.tic\\TIC-80\\rift\\?.lua"	-- jynx

local R={}
require("./sys/sys")(R)
require("./3d/scene")(R)
require("./3d/actor")(R)

SCENE=nil
MODEL=nil
ACTOR=nil

IS_FIRST=true
function TIC()
    local t = time()*.001;
    
    if IS_FIRST then
        SCENE=R.Scene:new()

        MODEL=R.Model:new()
--        MODEL:load(require("./data/model/cube"))
        MODEL:load(require("./data/model/cube-multipass"))
        ACTOR=R.Actor:new(MODEL)
        ACTOR:setDrawFn(R.poly.DrawDebug,0)
        ACTOR:setDrawPassFn("one", R.poly.Draw1Colour(2))

        SCENE:registerActor(ACTOR)        
        IS_FIRST=false
    end

    cls()
	R.tryBreak()

    local mat=R.M44:new(R.M44.ID)
    mat:mulM44(R.M44:newTrans(0,0,-6))
    mat:mulM44(R.M44:newRotY(t))
    ACTOR:setMat(mat)
    ACTOR:setDrawPassFn("two", R.poly.Draw1Colour((t*4)//1))

    local cam=SCENE:getCam()
    local y=math.sin(t)*.5
    cam:setPos(R.V4:new({0,y,0,1}))
--    cam:setAim(R.V4:new({0,y,0,-10}))

    SCENE:draw()
end

-- <PALETTE>
-- 000:1a1c2c5d275db13e53ef7d57ffcd75a7f07038b76425717929366f3b5dc941a6f673eff7f4f4f494b0c2566c86333c57
-- </PALETTE>

