diff options
Diffstat (limited to 'main.lua')
-rw-r--r-- | main.lua | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -30,6 +30,7 @@ local shader = honey.Shader{ } -- load models +local plane = honey.mesh.loadFile("assets/plane.obj")[1] local tetra = honey.mesh.loadFile("assets/tetrahedron.obj")[1] local cube = honey.mesh.loadFile("assets/cube.obj")[1] local octa = honey.mesh.loadFile("assets/octahedron.obj")[1] @@ -65,8 +66,19 @@ local leaf = { shader=shader, } local root = growLine(leaf, 24) +root.update = function(self, dt) + self.transform:rotateY(0.2 * math.pi * dt) +end level:addEntity(root) +local groundPlane = { + transform=Mat4():identity():translate(Vec3{0, -2, 0}):scale(Vec3{10, 10, 10}), + parent=false, + mesh=plane, + shader=shader, +} +level:addEntity(groundPlane) + -- close window on ESCAPE key window:setKeyCallback(function(_, key) if key == glfw.KEY_ESCAPE then @@ -74,6 +86,12 @@ window:setKeyCallback(function(_, key) end end) +-- resize window correctly +window:setFramebufferSizeCallback(function(_, width, height) + gl.Viewport(0, 0, width, height) + camera.projection:perspectiveResize(width/height) +end) + -- main loop honey.loop(window, function(dt) gl.ClearColor(0.2, 0.4, 1.0, 1.0) |