Small World Engine API Reference - v0.78.00
    Preparing search index...

    Class WorldWriter

    Serializes a live Object3D tree into a minimal glTF 2.0 JSON document -- the write-side counterpart to GltfLoader. See docs/adr/0010-maker-editor-architecture.md for why glTF + an SW_* extension namespace, rather than a bespoke format, and ADR 0017 for how individual extensions (light, prefab, stage zone, ...) plug into this writer via a registry instead of being hardcoded here.

    Phase 0 scope only:

    • Node hierarchy and transforms (Euler or quaternion, whichever the object actually has set).
    • One mesh's material, via native pbrMetallicRoughness -- no SW_* extension needed yet since StandardMaterial's fields map onto it directly.
    • Geometry export covers POSITION only (no normals/uvs/indices) -- enough to prove the round-trip mechanism end to end; richer attribute export is a later phase once Maker actually needs textured/lit preview meshes.
    Index
    • Serializes obj itself (and its subtree) as the document's sole top-level node -- unlike write(), which serializes root's children. Used for prefab export: obj stays exactly where it is in the live scene graph (never reparented, unlike Object3D.add()'s silent detach), so exporting a prefab from a selected object can't disturb the scene being edited.

      Parameters

      Returns GltfDocument