# app.py import gradio as gr import json import os from pathlib import Path import shutil def create_game_html(model_path): html_template = f""" Advanced 3D Open World Game
Controls:
W/S/A/D - Move
SPACE - Jump
Mouse - Look Around
HP: 100
Weather:
""" return html_template def process_upload(glb_file): if glb_file is None: return None # 업로드된 파일 처리 upload_dir = "uploads" os.makedirs(upload_dir, exist_ok=True) file_path = Path(glb_file) dest_path = Path(upload_dir) / file_path.name shutil.copy(file_path, dest_path) # 게임 HTML 생성 game_html = create_game_html(str(dest_path)) # HTML 파일 저장 game_path = Path("game.html") with open(game_path, "w", encoding="utf-8") as f: f.write(game_html) return str(game_path) # Gradio 인터페이스 설정 iface = gr.Interface( fn=process_upload, inputs=[ gr.File( label="Upload Character Model (GLB)", type="filepath", file_types=[".glb"] ) ], outputs=gr.HTML(label="3D Open World Game"), title="Advanced 3D Open World Game Generator", description="Upload your character model (GLB) to create a 3D open world game with advanced features!", cache_examples=False ) if __name__ == "__main__": iface.launch()