• Apply demo-grade optimisations to a SceneModel in place.

    Passes run in order:

    1. Geometry splitting — every SceneGeometry whose vertex count exceeds maxVertices or whose primitive count exceeds maxPrimitives is split into two via splitSceneGeometry (whole-triangle midpoint partition); the worklist-driven loop repeats until no piece exceeds either threshold. Each SceneMesh that referenced the pre-split geometry is replicated onto both pieces (detach + destroy + recreate + reattach), so the parent SceneObject keeps its full geometric coverage. New mesh / geometry ids are suffixed _a / _b per split to stay stable in inspectors.

    2. Unused-resource prune — mark-and-sweep destruction of orphan meshes (not attached to a SceneObject), empty SceneObjects (no live meshes), geometries (no live mesh references via geometryId), materials (no live mesh materialId), transforms (no live mesh parentTransform and no live transform parent-of), and textures (no live material referencing them). Useful after authoring tools / loaders that emit speculative resources, and after applyIFCMaterials / MaterialsPalette.paintMaterial which leave the original mesh-bound materials (and their textures) behind.

    Before either pass runs, inspectSceneModel inspects the SceneModel and any errors (dangling references, malformed indices, transform cycles, non-finite matrices) cause this function to refuse to run rather than propagate corruption. Warnings are logged via console.warn and don't block.

    Future passes will land here too — geometry deduplication (instancing repeated meshes), batch coalescing (merging meshes that share material + transform), unused-vertex pruning, etc.

    Parameters

    Returns SDKResult<void>

    SDKResult — ok: true once every pass has completed; ok: false when the SceneModel is missing, destroyed, or already finalised, or when an underlying mesh / geometry operation fails.