如何使用react-三纤维在react js中旋转整个画布?

Lal*_*124 5 javascript three.js reactjs react-three-fiber

我遵循了这个 codrops教程,了解如何使用 React-Three-Fiber 制作可滚动网站。

我对其进行了相当多的修改,将所有项目居中并删除了 RGB 分割效果。现在我想旋转整个滚动区域/画布,以实现类似于此页面的对角滚动效果。是否可以将滚动区域作为一个整体进行旋转,还是必须使用 mesh.rotate.z =... 等单独旋转每个组件?

完整示例代码

将所有内容组合在一起的代码:

function App() {
 const scrollArea = useRef()
 const onScroll = e => (state.top.current = e.target.scrollTop)
 useEffect(() => void onScroll({ target: scrollArea.current }), [])
 return (
 <>
  <Canvas className="canvas" concurrent pixelRatio={1} orthographic camera={{ zoom: 
    state.zoom, position: [0, 0, 500] }}>
    <Suspense fallback={<Dom center className="loading" children="Loading..." />}>
      <Content />
      <Startup />
    </Suspense>
  </Canvas>
  <div className="scrollArea" ref={scrollArea} onScroll={onScroll}>
    {new Array(state.sections).fill().map((_, index) => (
      <div key={index} id={"0" + index} style={{ height: `${(state.pages / 
      state.sections) * 47}vh` }} />//site length
    ))}
    </div>
    <div className="frame">
    <div className="frame__links">
      <a className="frame__link" href="http://tympanus.net/Tutorials/PhysicsMenu/">
        Work
      </a>
      <a className="frame__link" href="https://tympanus.net/codrops/?p=45441">
        About
      </a>
    </div>
  </div>

</>
)}
Run Code Online (Sandbox Code Playgroud)

Lal*_*124 4

我通过将我的内容放入一个组中来解决这个问题,然后我像这样旋转:

 <group rotation-z={0.025} rotation-y={0.0} rotation-x={0.05}>
Run Code Online (Sandbox Code Playgroud)