local ecs = require 'honey.ecs.ecs' local module = {} setmetatable(module, {__index=_G}) setfenv(1, module) --===== transform cascading =====-- local function recursiveTransform(db, id, node) if node._visited then return node._matrix end if not node.parent then node._matrix = node.matrix else local parentNode = db:getComponent(node.parent, "node") local parentMatrix = recursiveTransform(db, node.parent, parentNode) node._matrix = parentMatrix * node.matrix if node.name then if not parentNode._child then parentNode._child = {} end parentNode._child[node.name] = ecs.Accessor(db, id) end end node._visited = true return node._matrix end system = {ecs.System("node", function(db, dt, params) local nodes = db:queryComponent("node") -- prepare nodes for id, node in pairs(nodes) do node._visited = false node._child = nil end -- compute nodes for id, node in pairs(nodes) do recursiveTransform(db, id, node) end end)} return module