Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
796 views
in Technique[技术] by (71.8m points)

javascript - Importing useGLTF from '@react-three/drei/useGLTF' cause Module not found:

I have installed the react three fiber here's a dependences

"dependencies": {
"@react-three/drei": "^3.0.0",
"@testing-library/jest-dom": "^5.11.9",
"@testing-library/react": "^11.2.3",
"@testing-library/user-event": "^12.6.0",
"drei": "^2.2.21",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-scripts": "4.0.1",
"react-spring": "^8.0.27",
"react-three-fiber": "^5.3.18",
"three": "^0.125.1",
"web-vitals": "^0.2.4"

},

and I run npm i drei

after it, I tried to import useGLTF

import { useGLTF } from '@react-three/drei/useGLTF'

and I got error

./src/Components/Three/Scene.js
Module not found: Can't resolve '@react-three/drei/useGLTF' in 'D:coding
eactmincraftsrcComponentsThree'

I decided to check the file manually inside @react-three/drei/useGLTF but there's no name such as useGLTF

do I need to run something else ?

question from:https://stackoverflow.com/questions/65950660/importing-usegltf-from-react-three-drei-usegltf-cause-module-not-found

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Damn. after some time I found useGLTF inside drei/core/useGLTF.

import { useGLTF } from '@react-three/drei/core/useGLTF'

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...