private static JavaFunction createModel(final ShaderProgram shader) {
        return new JavaFunction() {
            @Override
            public int call(LuaCallFrame lcf, int argCount) {
                ArrayList<Face> faces = new ArrayList<Face>();
                for (int i=0;i<argCount;i++) {
                    if (lcf.get(i) instanceof Face) {
                        Face f = (Face) lcf.get(i);
                        faces.add(f);
                    } else if (lcf.get(i) instanceof LuaTable) {
                        LuaTable table = (LuaTable) lcf.get(i);
                        for (int x=1;x<=table.len();x++) {
                            if (table.rawget(x) instanceof Face) {
                                faces.add((Face)table.rawget(x));
                            }
                        }
                    } else if (lcf.get(i) instanceof Collection) {
                        Collection<Face> subList = (Collection<Face>)lcf.get(i);
                        faces.addAll(subList);
                    }
                }
                Model m = new Model(shader, faces);
                lcf.push(m);
                return 1;
            }
        };
    }