Skip to content

Persistence

Timeline: Feb 5, 2026 | Status: done

Save/load scene state.


Goals

  • JSON Serialize
    • SO state (bounds)
    • SO orientation (moved from O_Scene to Smart_Object as SOT)
    • camera position (eye, center, up)
  • Save to localStorage (single scene, auto-save on drag)
  • Load latest one on app start
  • Clear/reset option (reset button in Controls, white bg, black hover)

Format Research

FormatSpeedSizeHuman ReadableNotes
JSONBaselineLargestYesUniversal, easy debugging
MessagePack~37% faster~15% smallerNoBest performance overall
CBOR~27% faster~27% smallerNoAWS-friendly, JSON-like schema
BSONSlower encode, faster decodeLarger than MPNoMongoDB native

Key findings:

  • MessagePack wins on raw performance — 10K objects serialize in ~918μs
  • CBOR is the best drop-in JSON replacement (same data model, binary encoding)
  • JSON still solid for debugging and human editing

Decision: Use JSON — readable, debuggable, localStorage-friendly. If performance becomes an issue, use MessagePack or CBOR (same structure, just binary).

Sources:

Implementation

  • Smart_Object.serialize() / Smart_Object.deserialize() — name + 6 bounds + orientation quat
  • Camera.serialize() / Camera.deserialize() — eye, center, up vectors
  • Scenes manager — save/load/clear via Preferences localStorage wrapper
  • Setup.ts — loads saved state on init, saves after every drag

Notes