我正在使用 React,这是我第一次尝试Three.js / @react-three/fiber / @react-three/drei。
我使用从 Sketchfab.com 下载的这个3D 模型,它对我的网站来说显得太大了。
我想让模型尺寸更小,但找不到任何解决方案。
我已经尝试过这个解决方案,但它并没有改变任何东西https://stackoverflow.com/a/69676440/17156530
你能看看我的代码,看看我做错了什么吗?因为我正在学习 2020 年的教程,所以可能有些功能现在不起作用。
感谢你们!:)
我的文件树的屏幕截图:
这是我的代码:
import React, { Suspense } from 'react'
import './App.css';
import Header from './components/Header'
import { Section } from './components/Section'
import { Canvas } from '@react-three/fiber'
import { Html, useGLTF } from '@react-three/drei'
const Model = () => { const gltf = useGLTF('/angel.gltf') return <primitive object={gltf.scene} dispose={null} /> }
const Lights = () => { return (
<>
<ambientLight intensity={0.3} />
<directionalLight position={[10, 10, 5]} intensity={1} />
<directionalLight position={[0, 10, 0]} intensity={1.5} />
<spotLight intensity={1} position={[1000, 0, 0]} />
</>
) }
const HTMLContent = () => { return (
<Section factor={1.5} offset={1}>
<group position={[0, 46, 0]}>
<mesh position={[0, -40, 0]}>
<Model scale={[0.1, 0.1, 0.1]} />
</mesh>
<Html fullscreen>
<div className="container">
<h1 className="title">Hello</h1>
</div>
</Html>
</group>
</Section> ) }
function App() {
return (
<>
<Header />
<Canvas
colorManagement
camera={{position: [0, 0, 20], fov: 70}}
>
<Lights />
<Suspense fallback={null}>
<HTMLContent />
</Suspense>
</Canvas>
</>
);
}
export default App;