local M = {} function M.write3d(maze, width, height, depth, filename) local scale = 5 local inverted = true local out = io.open(filename, "w") out:write("// Generated by multimaze (lua)\n") out:write("// Hit the Render button (F6) to make the preview look better\n") out:write("// Uncomment to make the preview look transclucent\n") out:write("// color(\"red\", 0.25)\n"); out:write("union() {\n") for z = 0, depth - 1, 1 do for y = 0, height - 1, 1 do for x = 0, width - 1, 1 do if (maze[z][y][x] == "#" and not inverted) or (maze[z][y][x] == " " and inverted) then out:write("\ttranslate(["..x*scale..", "..y*scale..", "..z*scale.."]) cube(size = "..scale..");\n") end end end end out:write("}\n") out:close() end return M