diff options
Diffstat (limited to 'demo/MeshInstance.lua')
-rw-r--r-- | demo/MeshInstance.lua | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/demo/MeshInstance.lua b/demo/MeshInstance.lua index 7164f18..a3e6da2 100644 --- a/demo/MeshInstance.lua +++ b/demo/MeshInstance.lua @@ -5,11 +5,17 @@ local MeshInstance = {} MeshInstance.prototype = {} setmetatable(MeshInstance.prototype, { __index = Node.prototype}) -MeshInstance.prototype.draw = function(self, shader, camera) +MeshInstance.prototype.draw = function(self, camera, shader) + local shader = shader or self.shader + honey.shader.set_mat4(shader, 'model', self.transform.array) honey.shader.set_mat4(shader, 'view', camera.view.array) honey.shader.set_mat4(shader, 'projection', camera.projection.array) honey.mesh.draw(self.mesh, shader) + + for _, child in ipairs(self.children) do + child:draw(camera) + end end -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -19,13 +25,13 @@ MeshInstance.mt.__index = MeshInstance.prototype -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -MeshInstance.new = function(parent, position, rotation, scale, mesh) +MeshInstance.new = function(parent, position, rotation, scale, mesh, shader) local meshinstance = Node.new(parent, position, rotation, scale) + meshinstance.mesh = mesh + meshinstance.shader = shader setmetatable(meshinstance, MeshInstance.mt) - meshinstance.mesh = mesh - return meshinstance end |