-
Hey there Perhaps I'm missing something, but I'm wondering how I can get a reference to the or My use-case is a top-level component that contains a material using two FBO's, . Based on the scroller's progress, I'd like to transition from one scene to the adjaced scene. Typically something like this roughly function TransitionScene() {
const sceneAFBO = useFBO();
const sceneBFBO= useFBO();
const sceneARef= useRef();
const sceneBRef = useRef();
useFrame(({ gl, camera }) => {
if (sceneARef.current) {
gl.setRenderTarget(sceneAFBO);
gl.clearColor(0, 0, 0, 0);
gl.render(sceneARef.current, camera);
}
if (sceneBRef.current) {
gl.setRenderTarget(sceneBFBO);
gl.clearColor(0, 0, 0, 0);
gl.render(sceneBRef.current, camera);
}
gl.setRenderTarget(null);
});
return (
<>
<scene ref={sceneARef}>
<Sphere args={[1, 32, 32]} />
</scene>
<scene ref={sceneBRef}>
<Box args={[1, 1, 1]} />
</scene>
<ScreenQuad>
<TransitionMaterial sceneA={sceneAFBO} sceneB={sceneBFBO} progress={progress} />
</ScreenQuad>
</>
);
} Is this possible? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 9 replies
-
Hi @mokargas - interesting use case! Haven't done this type of transition with the scrollrig yet, but should be possible. I guess you only need the scrollrig if you are planning on syncing meshes inside each scene with DOM elements, is that the idea? The scrollrig has a global render loop that renders the default r3f scene |
Beta Was this translation helpful? Give feedback.
Got it!
You also need to make sure the canvas children render inside your local scenes (sceneA, sceneB) instead of the global scene.
I pushed a new version
v8.13.1
where theScrollScene
accepts ascene
property. If provided it will portal the children to that scene. e693906So you can do something like: