WIP checkpoint: US-1: glTF Asset Upload with Metadata Extraction

This commit is contained in:
2026-08-19 14:45:38 +00:00
parent ffbc4849a7
commit d3496d8c67
+31
View File
@@ -3,6 +3,8 @@ from sqlalchemy.dialects.postgresql import ENUM
from sqlalchemy.orm import relationship from sqlalchemy.orm import relationship
from sqlalchemy.sql import func from sqlalchemy.sql import func
import enum import enum
import json
from typing import Any, Optional
from app.database import Base from app.database import Base
@@ -38,3 +40,32 @@ class Asset(Base):
owner = relationship("User", back_populates="assets") owner = relationship("User", back_populates="assets")
world = relationship("World", back_populates="assets") world = relationship("World", back_populates="assets")
# ------------------------------------------------------------------
# Computed properties
# ------------------------------------------------------------------
@property
def has_gltf_metadata(self) -> bool:
"""Return True when metadata_json contains glTF-specific keys.
glTF metadata is considered present when the stored JSON contains at
least one of the keys that *extract_gltf_metadata* produces
(mesh_count, vertex_count, has_animation, texture_refs,
bounding_box_min, bounding_box_max).
"""
if not self.metadata_json:
return False
try:
data: dict[str, Any] = json.loads(self.metadata_json)
except (json.JSONDecodeError, TypeError):
return False
gltf_keys = {
"mesh_count",
"vertex_count",
"has_animation",
"texture_refs",
"bounding_box_min",
"bounding_box_max",
}
return bool(gltf_keys & data.keys())