Spaces:
Running on Zero
Running on Zero
File size: 863 Bytes
648cdec | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | import os
import requests
import tarfile
import trimesh
HELMET_URL = "https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/refs/heads/main/2.0/DamagedHelmet/glTF-Binary/DamagedHelmet.glb"
CACHE_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), "cache")
def download_file(url, path):
print(f"Downloading from {url} ...")
resp = requests.get(url, stream=True)
resp.raise_for_status()
with open(path, "wb") as f:
for chunk in resp.iter_content(chunk_size=8192):
f.write(chunk)
print(f"Saved to {path}")
def get_helmet() -> trimesh.Trimesh:
HELMET_PATH = os.path.join(CACHE_DIR, "helmet.glb")
if not os.path.exists(HELMET_PATH):
os.makedirs(CACHE_DIR, exist_ok=True)
download_file(HELMET_URL, HELMET_PATH)
return trimesh.load(HELMET_PATH)
|