Skip to content

Improve serialization robustness: schema preservation, triangulation, and checksum alignment#22

Merged
afshawnlotfi merged 5 commits intomainfrom
improve/extraction
Apr 9, 2026
Merged

Improve serialization robustness: schema preservation, triangulation, and checksum alignment#22
afshawnlotfi merged 5 commits intomainfrom
improve/extraction

Conversation

@afshawnlotfi
Copy link
Copy Markdown
Member

@afshawnlotfi afshawnlotfi commented Apr 7, 2026

Enhanced schema utilities and add earcut triangulation

  • Schema Enhancements: Improved discriminator matching in SchemaUtils to validate all Literal fields present in both model and data
  • Computed Fields: Updated serialization to include computed fields (bbox, render_order) when extracting BaseModels
  • Triangulation Support: Added earcut library dependency for triangulating non-triangle faces in mesh processing
  • TypeScript Updates: Enhanced mesh.ts and packable-worker.ts with triangulation capability

Packable schema handling and checksum improvements

  • Schema Preservation: Added _original_json_schema to Packable class to preserve schema during reconstruction (for dynamic models with numpy fields)
  • Fallback Mechanism: Added error handling in extract() to use preserved schema when model_json_schema() fails
  • Checksum Refactor: Rewrote compute_dict_checksum() to compute SHA256 from compact JSON + asset bytes (removing orjson dependency)
  • Type Safety: Improved schema resolution for untyped references (object/Any types)

Refined JSON schema handling and TypeScript alignment

  • Better Abstraction: Extracted _get_json_schema() method for cleaner fallback logic with improved documentation
  • TypeScript Parity: Updated checksum computation to match TypeScript implementation (compact JSON with (',', ':') separators and conditional asset bytes)
  • Code Clarity: Enhanced normal computation in meshToRawGeometry() with clearer inline comments and improved formatting
  • Edge Case Handling: Refined logic for detecting array references vs raw dict values with $ref keys

Overall Focus: These commits improve serialization robustness, cross-language consistency (Python/TypeScript), and support for dynamic/complex models.

…lback mechanism; update checksum computation for data dicts to align with TypeScript implementation
@afshawnlotfi afshawnlotfi changed the title Enhance schema utilities and serialization; add earcut for triangulat… Improve serialization robustness: schema preservation, triangulation, and checksum alignment Apr 9, 2026
@afshawnlotfi afshawnlotfi merged commit fb9a219 into main Apr 9, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant