feat(simulation): optimize and persist collision viewing
This commit is contained in:
@@ -12,6 +12,7 @@ from k1link.simulation.gaussian_pipeline_gateway import GaussianPipelineGatewayE
|
||||
from k1link.simulation.projects import (
|
||||
MAX_UPLOAD_CHUNK_BYTES,
|
||||
PROJECT_SCHEMA,
|
||||
VIEWER_SETTINGS_SCHEMA,
|
||||
SimulationProjectConflictError,
|
||||
SimulationProjectError,
|
||||
SimulationProjectNotFoundError,
|
||||
@@ -45,6 +46,30 @@ class SimulationProjectUpdate(BaseModel):
|
||||
scene_type: Literal["interior", "outdoor", "object"]
|
||||
|
||||
|
||||
class SimulationLayerViewerSettings(BaseModel):
|
||||
model_config = ConfigDict(extra="forbid", frozen=True)
|
||||
|
||||
inverted: bool
|
||||
axis: Literal["x", "y", "z"]
|
||||
|
||||
|
||||
class SimulationCameraViewerSettings(BaseModel):
|
||||
model_config = ConfigDict(extra="forbid", frozen=True)
|
||||
|
||||
invert_horizontal: bool
|
||||
invert_vertical: bool
|
||||
|
||||
|
||||
class SimulationViewerSettings(BaseModel):
|
||||
model_config = ConfigDict(extra="forbid", frozen=True)
|
||||
|
||||
schema_version: Literal["missioncore.simulation-viewer-settings/v1"] = VIEWER_SETTINGS_SCHEMA
|
||||
quality: Literal["low", "medium", "high", "ultra", "maximum"]
|
||||
visual: SimulationLayerViewerSettings
|
||||
collision: SimulationLayerViewerSettings
|
||||
camera: SimulationCameraViewerSettings
|
||||
|
||||
|
||||
class SimulationProjectDocument(BaseModel):
|
||||
model_config = ConfigDict(extra="forbid")
|
||||
|
||||
@@ -57,6 +82,7 @@ class SimulationProjectDocument(BaseModel):
|
||||
provider: dict[str, Any]
|
||||
artifacts: list[dict[str, Any]]
|
||||
world_manifest: dict[str, Any] | None
|
||||
viewer_settings: SimulationViewerSettings
|
||||
error: str | None
|
||||
created_at_utc: str
|
||||
updated_at_utc: str
|
||||
@@ -117,6 +143,21 @@ def build_simulation_projects_router(
|
||||
except SimulationProjectError as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
||||
|
||||
@router.put(
|
||||
"/projects/{project_id}/viewer-settings",
|
||||
response_model=SimulationProjectDocument,
|
||||
)
|
||||
def update_viewer_settings(
|
||||
project_id: str,
|
||||
request: SimulationViewerSettings,
|
||||
) -> dict[str, Any]:
|
||||
try:
|
||||
return store.update_viewer_settings(project_id, request.model_dump())
|
||||
except SimulationProjectNotFoundError as exc:
|
||||
raise HTTPException(status_code=404, detail="Проект симуляции не найден.") from exc
|
||||
except SimulationProjectError as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
||||
|
||||
@router.head("/projects/{project_id}/source/{file_id}")
|
||||
def source_upload_state(project_id: str, file_id: str) -> Response:
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user