import { Mesh, OrthographicCamera, Scene } from "three";
import { FULL_SCREEN_TRIANGLE_GEOMETRY } from "../../geometry/FULL_SCREEN_TRIANGLE_GEOMETRY.js";
import { three_setSceneAutoUpdate } from "../../three/three_setSceneAutoUpdate.js";


const quad = new Mesh(FULL_SCREEN_TRIANGLE_GEOMETRY, null);
quad.frustumCulled = false;
quad.matrixAutoUpdate = false;
quad.matrixWorldNeedsUpdate = false;


const camera = new OrthographicCamera(-1, 1, 1, -1, 0, 1);
const scene = new Scene();

three_setSceneAutoUpdate(scene, false);
scene.matrixAutoUpdate = false;
scene.matrixWorldNeedsUpdate = false;

scene.add(quad);

/**
 *
 * @param {WebGLRenderer} renderer
 * @param {Material} material
 */
export function renderScreenSpace(renderer, material) {
    quad.material = material;

    renderer.render(scene, camera);

    //
    quad.material = null;
}
