Skip to Content
ScenebrewDevelopers

Scene models: references and variants

What a scene's GLB references from the library, the four variants every model route serves, and how a renderer resolves the references.

A scene's model is built from its theme's library assets: the materials that paint its terrain and the meshes of its props. The model can carry those assets in two ways, chosen separately for materials and for meshes:

  • embed — the asset is inside the GLB: a material with its texture maps, a prop with its mesh. One self-contained file that any glTF viewer opens.
  • reference — the GLB names the library asset instead. A material is thin: no images, its fallback colour as baseColorFactor, and the library material it stands for. A prop is an empty node at its place, naming the library mesh to put there. The renderer resolves the names against the project's library, so a texture that a hundred scenes use is downloaded once.

The variants

Every route and tool that returns the model takes materials and meshes, each reference or embed. The default is embed / embed, the self-contained file:

Route or toolParameters
GET /v1/scenes/{scene_id}/artifacts (list_scene_artifacts)materials, meshes
GET /v1/scenes/{scene_id}/artifacts/model (get_scene_artifact)materials, meshes
GET /v1/scenes/{scene_id}/artifacts/model/content (download_scene_artifact)materials, meshes — 307 to the bytes
MCP list_scene_artifacts, get_scene_artifactmaterials, meshes

The artifact record says which variant its download_url serves in its own materials and meshes fields. GET /v1/scenes/{scene_id} lists the model as stored and never builds a variant.

# props as references, materials embedded
curl -s "https://api.scenebrew.com/v1/scenes/$SCENE_ID/artifacts/model?materials=embed&meshes=reference" \
  -H "Authorization: Bearer $SCENEBREW_API_KEY" | jq '{materials, meshes, size_bytes, download_url}'

The first request for a variant may take several seconds while it is built; after that it is served from storage, and every later request returns the same bytes (the same content_hash). A model brewed before references existed is served as stored, whatever you ask for. It is labelled embed / embed and carries no references.

Each Scenebrew client picks the variant that suits it:

ClientMaterialsMeshes
Scenebrew app viewerreferenceembed
Unity packagereferencereference (adjustable in the Scenebrew window)
Downloads, MCPembedembed

What the GLB carries

Everything a renderer needs is in extras.scenebrew, at three places in the glTF. The normative schema is glb-extras.schema.json (contract version 1.0.0). Validate an object against the $defs entry its position names. Unknown keys are not allowed: a new key means a new contract version.

The scene (scenes[i].extras.scenebrew) records the variant the file is in, and the blueprint it was cooked from:

{
  "schema_version": "1.0.0",
  "blueprint": "0199a1c0-…",
  "materials": "reference",
  "meshes": "embed"
}

Every material (materials[i].extras.scenebrew) names the library material it stands for. asset is null for a surface label that the theme binds no material to, which shows only its fallback colour. fallback_color is linear RGBA. In a reference file it is the material's baseColorFactor too, so an unresolved material is never white.

{
  "asset": "01a13906-1bff-…",
  "label": "path",
  "role": "terrain",
  "body": "terrain",
  "fallback_color": [0.1119, 0.1022, 0.0999, 1.0]
}

Every prop instance node (nodes[i].extras.scenebrew) names what placed it: the recipe, the PEG point it stands on and, in mesh, the library mesh, with the digest of its file and any material slots the recipe overrides ("*" overrides every slot). The node's transform already includes the mesh's fit and pivot, so place the mesh under the node as authored and apply nothing else.

{
  "recipe": "01a13906-a156-…",
  "node": "I2",
  "role": "object",
  "mesh": {
    "asset": "01a13905-e87b-…",
    "sha256": "820eb913…",
    "materials": { "*": "01a13906-747b-…" }
  }
}

Resolve the references

POST /v1/projects/{project_id}/assets/resolve turns up to 100 asset ids into what a renderer draws, in request order. Ask only for the roles you bind:

curl -s -X POST "https://api.scenebrew.com/v1/projects/$PROJECT_ID/assets/resolve" \
  -H "Authorization: Bearer $SCENEBREW_API_KEY" -H "Content-Type: application/json" \
  -d '{"ids": ["01a13906-1bff-…", "01a12a5a-5474-…"], "roles": ["albedo", "normal", "ao"]}'
{
  "items": [
    {
      "id": "01a13906-1bff-…",
      "status": "ok",
      "type": "material",
      "fallback_color": "#5e5a59",
      "normal_convention": "directx",
      "maps": {
        "albedo": {
          "asset_id": "01a13906-1bff-…",
          "role": "albedo",
          "sha256": "d0a06648…",
          "media_type": "image/png",
          "size_bytes": 2652324,
          "url": "https://api.scenebrew.com/v1/assets/01a13906-1bff-…/files/albedo?sha256=d0a06648…"
        },
        "normal": { "…": "…" }
      }
    },
    {
      "id": "01a12a5a-5474-…",
      "status": "not_found",
      "type": null,
      "fallback_color": null,
      "normal_convention": null,
      "maps": {}
    }
  ]
}
  • An id that is not an asset of the project comes back as not_found in its place; the call does not fail because of it.
  • Each map's url is content-addressed: it answers 307 to exactly the bytes its sha256 names, so a renderer can cache files by digest indefinitely. The download needs the same key.
  • A material channel bound to a standalone texture asset appears under the channel's role, with that texture's asset_id and role: "texture".
  • fallback_color is sRGB #rrggbb here; the GLB carries the same colour in linear.
  • normal_convention is opengl, directx or null (undecided, or no normal map). glTF reads normals in the OpenGL convention, so flip the green channel of a directx map when you bind it. In three.js, multiply the material's normalScale.y by -1 rather than setting it: GLTFLoader has already set it to -1 on every primitive without tangents, and library prop meshes carry none. An embedded variant has done all of this already.

Meshes resolve the same way: a mesh asset's mesh file is its GLB.

How the Scenebrew clients do it

The Scenebrew app (three.js) loads reference / embed. A GLTFLoader plugin reads the extras, the viewer resolves the material ids in batches and binds albedo, normal and ao as they arrive. Until they arrive, and permanently for an id that does not resolve, the material shows its fallback colour and the console names the asset. Decoded textures are shared across scenes by digest, and the file bytes are kept in the browser's Cache Storage, so a reload downloads no texture it already holds.

The Unity package (in preview) imports reference / reference. The scene's theme is imported into the project as Unity assets, and the scene becomes scene.prefab: a variant of the model whose materials are the theme's Materials and whose props are instances of the theme's mesh prefabs. When the theme is missing, the editor offers to import it. Without it, materials keep their fallback colours and props are not placed, and the import lists every asset it could not bind.

On this page