Essentially I would like to rotate the box in the plane with the camera controls in the following example. Every time I try and add the camera controls I end up rotating the plane. Eventually I would like to move the plane with scrollevents
and rotate the scene on the plane with controls.
function Box(props) {
return (
<mesh {...props}>
<boxBufferGeometry args={[60, 60, 60]} />
<meshNormalMaterial />
</mesh>
);
}
function Plane() {
const cam = useRef();
const [scene, target] = React.useMemo(() => {
const scene = new THREE.Scene();
scene.background = new THREE.Color('orange');
const target = new THREE.WebGLMultisampleRenderTarget(
window.innerWidth,
window.innerHeight,
{
minFilter: THREE.LinearFilter,
magFilter: THREE.LinearFilter,
format: THREE.RGBFormat,
stencilBuffer: false,
},
);
target.samples = 8;
return [scene, target];
}, []);
useFrame((state) => {
cam.current.position.z = 200;
state.gl.setRenderTarget(target);
state.gl.render(scene, cam.current);
state.gl.setRenderTarget(null);
});
return (
<>
<PerspectiveCamera ref={cam} />
{createPortal(<Box />, scene)}
<mesh>
<planeBufferGeometry attach="geometry" args={[160, 90]} />
<meshStandardMaterial attach="material" map={target.texture} />
</mesh>
</>
);
}
function App() {
return (
<Canvas
style={{ background: '#324466' }}
orthographic={true}
camera={{ position: [0, 0, 200] }}
>
<ambientLight intensity={0.5} />
<Plane />
</Canvas>
);
}