Hi all,
to achieve a Cover-Effect similar to CSS, my main Scene consists of a full-screen plane, onto which I’m rendering another scene (SceneA). The plane’s scale is set via drei’s useAspect.
<mesh scale={scale}>
<planeGeometry />
<sceneMaterial>
<RenderTexture attach="tex0">
<SceneA />
</RenderTexture>
</sceneMaterial>
</mesh>
Inside SceneA.jsx I’m trying to implement a subtle camera movement inside useFrame().
// Camera Movement
const target = new THREE.Vector2();
useFrame((state) => {
target.x = 1 - state.pointer.x * 0.01 * 5;
target.y = state.pointer.y * 0.07 * 5;
camera.position.x = THREE.MathUtils.lerp(
camera.position.x,
-target.x - camera.position.x,
0.05
);
camera.position.y = THREE.MathUtils.lerp(
camera.position.y,
target.y - camera.position.y,
0.05
);
});
However, the mouse movement is only registered on the plane in the MainScene. Although the plane stays visible and shows my SceneA, it’s as if the movement only get’s tracked on the initial viewport, as soon as i scroll down and the initial viewport ist out of sight, the movement doesn’t update any more.
Any idea why this is happening, or how I could implement this better?
I could just directly put everything into my MainScene and scrap the plane and rendertexture approach, but then I lose the CSS-Cover effect…