SceneLayerParser

Decodes an I3S (SLPK) scene layer into a runtime Tileset tree — the paged I3S sibling of TilesetParser. The hierarchy lives across nodepages/{n}.json pulled on demand via a NodePageSource, so parsing is suspend.

I3S → runtime model: node children indices → Tile3d.children; OBB → conservative local BoundingVolume.Sphere (radius = OBB diagonal) placed by Tile3d.tileToWorld from GeographicToWorld; lodThreshold (maxScreenThreshold[SQ]) → Tile3d.geometricError = referenceSSE·2·radius/threshold (baked so the traverser's default SSE selects at I3S-native detail). Content decodes separately; Tile3d.contentUri points at the geometry via the slpk: scheme.

Scope: I3S 1.7+ compact node pages, mesh profiles. TODO(scale): builds the tree eagerly — multi-million-node sets should materialise children lazily at traversal (like SubtreeReader); buildNode is factored for that. TODO(verify): OBB-center CRS + LoD metric on more datasets.

Types

Link copied to clipboard
fun interface GeographicToWorld

Geographic (WGS84 degrees + ellipsoidal m) → the node's tileToWorld matrix. Backed by the layer's globe.

Link copied to clipboard
fun interface NodePageSource

Supplies raw nodepages/{pageIndex}.json bodies (from the SLPK archive). Null = absent.

Functions

Link copied to clipboard
suspend fun parse(doc: SceneLayerDoc, archiveId: String, nodePages: SceneLayerParser.NodePageSource, geoToWorld: SceneLayerParser.GeographicToWorld, referenceScreenSpaceError: Double = 16.0, preferDracoGeometry: Boolean = GltfDecoderRegistry.dracoDecoder != null): Tileset

Pre-parsed-document overload — callers that inspect the doc themselves (e.g. for the vertex CRS) avoid decoding the JSON twice.

suspend fun parse(sceneLayerJson: String, archiveId: String, nodePages: SceneLayerParser.NodePageSource, geoToWorld: SceneLayerParser.GeographicToWorld, referenceScreenSpaceError: Double = 16.0, preferDracoGeometry: Boolean = GltfDecoderRegistry.dracoDecoder != null): Tileset