UNPKG

mylingo3d

Version:

Lingo3D is a React/Vue 3d game development framework that ships with a complete visual editor

44 lines 1.41 kB
import { MeshBasicMaterial } from "three"; import { getSelectiveBloomComposer } from "../../../../states/useSelectiveBloomComposer"; import scene from "../../../scene"; export const bloomPtr = [false]; export const addBloom = (target) => { target.userData.bloom = true; bloomPtr[0] = true; }; export const deleteBloom = (target) => { target.userData.bloom = false; }; let sceneBackground; const blackMaterial = new MeshBasicMaterial({ color: 0x000000 }); let restoreMaterials = []; const darkenRecursive = (children) => { for (const child of children) { if (child.userData.bloom || !child.visible) continue; darkenRecursive(child.children); if (child.material) { restoreMaterials.push([child.material, child]); child.material = blackMaterial; } } }; const darken = () => { darkenRecursive(scene.children); if (scene.background) { sceneBackground = scene.background; scene.background = null; } }; const restore = () => { for (const [material, object] of restoreMaterials) object.material = material; restoreMaterials = []; sceneBackground && (scene.background = sceneBackground); }; export default () => { darken(); getSelectiveBloomComposer()?.render(); restore(); }; //# sourceMappingURL=renderSelectiveBloom.js.map