room-visualizer / routes /materials.py
github-actions[bot]
Automated Deploy: 909dd51229176b0c49faf7e3156f93b4eebe8cd7
c97431f
Raw History Blame Contribute Delete
681 Bytes
"""Material map preparation route."""
from fastapi import APIRouter, File, Form, UploadFile
from errors import bad_request
from services.materials.cache import build_tile_material_package
router = APIRouter(prefix="/materials", tags=["materials"])
@router.post("/prepare")
async def prepare_material_maps(
file: UploadFile = File(...),
base_roughness: float = Form(0.42),
):
if file.content_type and not file.content_type.startswith("image/"):
bad_request("Upload must be a tile image.")
contents = await file.read()
if not contents:
bad_request("Upload must not be empty.")
return build_tile_material_package(contents, base_roughness)