/**
 * ALGA ARENA — WebGL Dispose Helper
 * Clears GPU caches on scene unmount
 */

'use strict';

window.CinematicDispose = (() => {
    const clear = (scene) => {
        if (!scene) return;
        scene.traverse(obj => {
            if (!obj.isMesh) return;
            obj.geometry.dispose();

            if (Array.isArray(obj.material)) {
                obj.material.forEach(m => m.dispose());
            } else {
                obj.material.dispose();
            }
        });
    };

    return { clear };
})();
