Skip to content

Refactor Packable Format with AssetStore, Caching & Checksum Improvements#18

Merged
afshawnlotfi merged 4 commits intomainfrom
overhaul/format
Feb 4, 2026
Merged

Refactor Packable Format with AssetStore, Caching & Checksum Improvements#18
afshawnlotfi merged 4 commits intomainfrom
overhaul/format

Conversation

@afshawnlotfi
Copy link
Member

@afshawnlotfi afshawnlotfi commented Feb 4, 2026

Summary

This PR introduces a major refactor of the meshly serialization format, replacing the legacy packed array format with a cleaner, content-addressable asset-based approach. It also adds the AssetStore for file-based asset management with deduplication, enhances caching mechanisms, and improves the overall developer experience.

Key Changes

🏗️ New Serialization Format

  • New zip structure: metadata/data.json + metadata/schema.json + assets/{checksum}.bin
  • Array references: Arrays now use $ref objects with embedded metadata (shape, dtype, itemsize)
  • JSON Schema integration: Schema file provides encoding hints (vertex_buffer, index_sequence, array)
  • Removes old packed array format (metadata length prefix + JSON metadata + encoded bytes)

📦 AssetStore Implementation

  • New AssetStore class for file-based asset management with content-addressable storage
  • Deduplication: Assets are stored by checksum, avoiding duplicate storage
  • save/load methods: Added save() and load() convenience methods to Packable
  • Ensures asset directory creation before writing
  • Enhanced __repr__ for better debugging

⚡ Caching & Performance

  • New AssetCache class with IndexedDB-backed LRU caching for browser environments
  • Memory cache layer for hot assets with configurable limits
  • createCachedProvider() helper for wrapping fetch functions with caching
  • Automatic eviction based on item count and total size limits

🔧 API Improvements

  • TypeScript: Added ExportConstants, JsonSchema, JsonSchemaUtils for format handling
  • TypeScript: ArrayUtils.decodeFromRefInfo() for decoding from new $ref format
  • TypeScript: Removed DataHandler, CachedAssetLoader in favor of simpler AssetProvider
  • Python: Simplified Packable.extract() and Packable.reconstruct() APIs
  • Renamed marker fields: markerIndicesmarkers, markerOffsetsmarkerSizes, markerTypesmarkerCellTypes

🧪 Test Improvements

  • Refactored tests to use Array type consistently
  • Improved Resource handling in tests
  • Added new test_asset_store.py for AssetStore coverage
  • Added Python integration test fixtures for TypeScript cross-platform testing
  • Removed deprecated tests (test_extract_assets.py, test_load_array.py)

Breaking Changes

  • TypeScript: DataHandler and CachedAssetLoader removed—use AssetCache and AssetProvider instead
  • TypeScript: MeshMetadata and MeshSize removed—metadata is now embedded in $ref objects
  • TypeScript: Marker field renames (markerIndicesmarkers, etc.)
  • Python: New zip format is not backward-compatible with legacy format

Migration Guide

Python:

# Before - manual extract/reconstruct
data, assets = packable.extract()

# After - simplified with AssetStore
store = AssetStore("/path/to/assets")
packable.save(store, "output.zip")
loaded = Packable.load(store, "output.zip")

- Removed test_load_array.py as it is no longer needed.
- Updated test_mesh.py to use Array type for normals and colors in CustomMesh.
- Modified test_packable.py to replace np.ndarray with Array in Packable subclasses.
- Enhanced test_resource.py to validate Resource and ResourceRef functionality, including checksum calculations and eager loading.
- Adjusted tests to ensure proper handling of Resource fields in Packable extraction and reconstruction.
- Improved lazy loading tests to verify correct behavior with Resource fields and arrays.
…lication and add save/load methods to Packable
@afshawnlotfi afshawnlotfi changed the title New format overhaul Refactor Packable Format with AssetStore, Caching & Checksum Improvements Feb 4, 2026
@afshawnlotfi afshawnlotfi merged commit 6b05a14 into main Feb 4, 2026
3 of 4 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