Luxar Viewer API Documentation - v2026.9.22
    Preparing search index...

    Module scene/scene-manager/render-pipeline/webgl-context-recovery

    WebGL context-loss / context-restoration concern extracted from scene/scene-manager.ts.

    Owns the full lifecycle of a graceful WebGL recovery:

    • Loss: a webglcontextlost event fires when the GPU driver crashes, the system hibernates, the browser hits its WebGL context limit, or GPU memory runs out. We preventDefault (the spec requires this for the browser to even attempt restoration), flip an isContextLost flag, and surface an error toast.

    • Restoration: when webglcontextrestored fires, we walk a deterministic rebuild order — renderer.resetState → postProcessing.rebuildAfterContextRestore → materialManager.rebuildAfterContextRestore → mark-scene-resources-dirty → updateRendererSize. Then we dispatch webgl-context-restored so subscribers (SceneLoader, NodeFactory, picking) can re-register their per-context state, and change to trigger a render.

    The class is a THREE.EventDispatcher so it stays compatible with the existing SceneManager pattern of dispatching webgl-context-restored on its own surface — the SceneManager forwards the event after receiving it from the recovery instance.

    Behavior is identical to the inline original: same guard messages, same rebuild order, same dispatch-events-after-restore sequence.

    WebGLContextRecovery
    WebGLContextRecoveryDeps
    markSceneResourcesDirtyForContextRestore