我有这两个组件:
相机.tsx
import { useGLTF } from "@react-three/drei"
export default function Camera() {
const gltf = useGLTF('/scene.gltf', true)
return (
<primitive object={gltf.scene} dispose={null}/>
)
}
Run Code Online (Sandbox Code Playgroud)
并在 Landing.tsx 中使用它
import { Suspense, useRef } from 'react';
import { Canvas, useFrame } from 'react-three-fiber';
import { Html } from '@react-three/drei';
import Camera from '../components/Camera';
import Lights from '../components/Lights';
export default function Landing() {
const mesh = useRef();
useFrame(() => {
(mesh.current as any).rotation.x += 0.01
})
return (
<div className='Landing'>
<Canvas colorManagement …Run Code Online (Sandbox Code Playgroud)