"""GLB file validation.""" import os from pathlib import Path from typing import Tuple class AssetValidator: """Validates GLB files for correctness.""" @staticmethod def validate_glb(glb_path: Path) -> Tuple[bool, str]: """Validate GLB file exists and is not corrupt.""" if not glb_path.exists(): return False, f"GLB file not found: {glb_path}" file_size = glb_path.stat().st_size if file_size < 1000: # Less than 1KB = corrupt return False, f"GLB file is corrupt (size: {file_size} bytes)" print(f"[Validator] GLB file valid: {file_size / 1e6:.2f} MB") # Optional: Deep validation with pygltflib try: import pygltflib gltf = pygltflib.GLTF2().load(str(glb_path)) if not gltf.meshes: return False, "GLB contains no meshes" print(f"[Validator] GLB contains {len(gltf.meshes)} meshes") except ImportError: print("[Validator] pygltflib not installed, skipping deep validation") except Exception as e: return False, f"GLB validation failed: {e}" return True, "Valid" @staticmethod def get_file_info(glb_path: Path) -> dict: """Get information about GLB file.""" if not glb_path.exists(): return {"exists": False} stat = glb_path.stat() return { "exists": True, "size_mb": stat.st_size / 1e6, "size_bytes": stat.st_size, "modified": stat.st_mtime, }