Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Webpack 无法导入带有Web包的.gltf文件_Webpack_Three.js_Webpack 4_Gltf - Fatal编程技术网

Webpack 无法导入带有Web包的.gltf文件

Webpack 无法导入带有Web包的.gltf文件,webpack,three.js,webpack-4,gltf,Webpack,Three.js,Webpack 4,Gltf,我正在努力使用Webpack导入.gltf文件(gatsby项目,使用react+Webpack+react三纤) 在开发模式中,我遇到以下错误: This relative module was not found: ⠀ * ../../static/gltf/bear_v2.gltf in ./src/components/CanvasWrapper.js error ✖ 「wdm」: ERROR in ./src/components/CanvasWrapper.js Module not

我正在努力使用Webpack导入.gltf文件(gatsby项目,使用react+Webpack+react三纤)

在开发模式中,我遇到以下错误:

This relative module was not found:
⠀
* ../../static/gltf/bear_v2.gltf in ./src/components/CanvasWrapper.js
error ✖ 「wdm」:
ERROR in ./src/components/CanvasWrapper.js
Module not found: Error: Can't resolve '../../static/gltf/bear_v2.gltf' in '/Volumes/Data/DOCUMENTS/_htdocs/slenterende-beer/src/components'
 @ ./src/components/CanvasWrapper.js 19:0-55 25:12-21 149:10-19
 @ ./src/pages/index.js
 @ ./.cache/sync-requires.js
 @ ./.cache/app.js
 @ multi ./node_modules/event-source-polyfill/src/eventsource.js (webpack)-hot-middleware/client.js?path=/__webpack_hmr&reload=true&overlay=false ./.cache/app
info ℹ 「wdm」: Failed to compile.
在开发期间,当我在
import
require
之间切换时,它突然起作用了。当我切换并重新启动项目时,它再次失败(直到我切换)。我认为这是一些奇怪的缓存问题(?)

我正在使用
gltf webpack loader
加载文件。 该文件现在放在
/static/gltf/model.gltf
中,但之前它们放在
/assets/
中,我想这是webpack不喜欢的

网页包规则:

加载代码:

进口位于第6行和第15行

以下是构建错误(在netlify上):


您使用gltf webpack loader的目的是什么?您应该能够使用“const modelPath=require('../../static/gltf/bear.gltf')获取路径,然后将其加载到“new GLTFLoader().load(modelPath,(res)…”@TomaszZieliński,然后我得到以下消息:./src/components/CanvasWrapper.js中的../assets/gltf/bear.gltf错误✖ 「wdm」:未找到./src/components/CanvasWrapper.js模块中的错误:错误:无法解析“../assets/gltf/bear.gltf”您使用gltf webpack loader的目的是什么?您应该能够使用“const modelPath=require('../static/gltf/bear.gltf')”获取路径,然后加载“new GLTFLoader().load(modelPath,(res)…”@TomaszZieliński然后我收到以下消息:../assets/gltf/bear.gltf in./src/components/CanvasWrapper.js error✖ 「wdm」:在./src/components/canvaswapper.js模块中找不到错误:错误:无法解析“../assets/gltf/bear.gltf”
10:02:42 PM:   Error: ./static/gltf/bear.gltf
10:02:42 PM:   Module not found: Error: Can't resolve './-0.707' in '/opt/build/repo/static/g  ltf'
10:02:42 PM:   resolve './-0.707' in '/opt/build/repo/static/gltf'
10:02:42 PM:     using description file: /opt/build/repo/package.json (relative path: ./static/gltf)
10:02:42 PM:       Field 'browser' doesn't contain a valid alias configuration
10:02:42 PM:       using description file: /opt/build/repo/package.json (relative path: ./sta  tic/gltf/-0.707)
10:02:42 PM:         no extension
10:02:42 PM:           Field 'browser' doesn't contain a valid alias configuration
10:02:42 PM:           /opt/build/repo/static/gltf/-0.707 doesn't exist
10:02:42 PM:         .mjs
10:02:42 PM:           Field 'browser' doesn't contain a valid alias configuration
10:02:42 PM:           /opt/build/repo/static/gltf/-0.707.mjs doesn't exist
10:02:42 PM:         .js
10:02:42 PM:           Field 'browser' doesn't contain a valid alias configuration
10:02:42 PM:           /opt/build/repo/static/gltf/-0.707.js doesn't exist
10:02:42 PM:         .jsx
10:02:42 PM:           Field 'browser' doesn't contain a valid alias configuration
10:02:42 PM:           /opt/build/repo/static/gltf/-0.707.jsx doesn't exist
10:02:42 PM:         .wasm
10:02:42 PM:           Field 'browser' doesn't contain a valid alias configuration
10:02:42 PM:           /opt/build/repo/static/gltf/-0.707.wasm doesn't exist
10:02:42 PM:         .json
10:02:42 PM:           Field 'browser' doesn't contain a valid alias configuration
10:02:42 PM:           /opt/build/repo/static/gltf/-0.707.json doesn't exist
10:02:42 PM:         as directory
10:02:42 PM:           /opt/build/repo/static/gltf/-0.707 doesn't exist
10:02:42 PM:   [/opt/build/repo/static/gltf/-0.707]
10:02:42 PM:   [/opt/build/repo/static/gltf/-0.707.mjs]
10:02:42 PM:   [/opt/build/repo/static/gltf/-0.707.js]
10:02:42 PM:   [/opt/build/repo/static/gltf/-0.707.jsx]
10:02:45 PM: failed during stage 'building site': Build script returned non-zero exit code: 1
10:02:42 PM:   [/opt/build/repo/static/gltf/-0.707.wasm]
10:02:42 PM:   [/opt/build/repo/static/gltf/-0.707.json]
10:02:42 PM:    @ ./static/gltf/bear.gltf ./-0.707