pmndrs / react-three-fiber

🇨🇭 A React renderer for Three.js
https://docs.pmnd.rs/react-three-fiber
MIT License
27.62k stars 1.6k forks source link

Three.js outlinePass add-on not working when implemented with R3F #3305

Closed MiguelG97 closed 3 months ago

MiguelG97 commented 4 months ago

I'm having a hard time using the R3F -postprocessing library so I decided to use raw threejs classes: By diving into the R3F extending third party library tutorials I managed to setup the renderPass and the outlinePass with typescript https://docs.pmnd.rs/react-three-fiber/tutorials/typescript

The code is in the following sandbox: https://codesandbox.io/p/sandbox/r3f-outlinepass-vdvhm8

Now I wish to add a mesh to the scene and trigger the outlinePass effect on it. I tried pushing the mesh to the selectedObjects but the Outline is not working:

    const outlinePass = ViewerModel.effectComposer!
      .passes[1] as unknown as OutlinePass;
    outlinePass.selectedObjects = [];
    outlinePass.selectedObjects.push(mesh);