动画
类型
类
默认用法
下面的每个示例都可以用 WebGPU(默认)或 WebGL 渲染器查看 —— 切换标签页进行对比。
- WebGPU
- WebGL
import { Scene, GLTFLoader, Animation } from 'react-three-lite'
function App() {
const handleCreated = async (scene, { camera }) => {
scene.position.set(0, -0.5, 0)
camera.position.set(0, 1.5, 3)
const model = await GLTFLoader('/models/perseverance-draco.glb', true)
scene.add(model)
const animation = new Animation(model)
animation.playAll()
}
return (
<Scene
style={{ marginTop: '10px', width: '100%', height: '300px' }}
bgColor="rgb(40, 42, 54)"
onCreated={handleCreated}
/>
)
}
import { Scene, GLTFLoader, Animation } from 'react-three-lite'
function App() {
const handleCreated = async (scene, { camera }) => {
scene.position.set(0, -0.5, 0)
camera.position.set(0, 1.5, 3)
const model = await GLTFLoader('/models/perseverance-draco.glb', true)
scene.add(model)
const animation = new Animation(model)
animation.playAll()
}
return (
<Scene
rendererType="webgl"
style={{ marginTop: '10px', width: '100%', height: '300px' }}
bgColor="rgb(40, 42, 54)"
onCreated={handleCreated}
/>
)
}