File size: 681 Bytes
532466c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
"""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)