我正在尝试.json
从three.js
. 但问题是three.js
格式.json
的使用已被弃用,但我仍然需要它。所以我开始寻找其他方法,并找到了提供此功能的存储库。但是当我尝试在连接模块的情况下构建项目时,webpack
在终端出现以下错误
。然后我安装了这个模块npm i fs
,终端出现同样的错误,浏览器控制台出现以下错误
。我将模块连接到index.js像这样:
const LegacyJSONLoader = require('three-legacyjsonloader');
...
<br/>**webpack.config.js:**
```javascript
const path = require("path");
module.exports = {
entry: "./src/index.js",
output: {
filename: "bundle.js",
path: path.resolve(__dirname, "dist")
}
}
包.json:
{
"name": "_____",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "webpack --mode development",
"build": "webpack --mode production"
},
"author": "",
"license": "ISC",
"dependencies": {
"fs": "0.0.1-security",
"three": "^0.119.1",
"three-legacyjsonloader": "^1.0.6", // модуль для загрузки *.json в three.js
"three.interaction": "^0.2.3"
},
"devDependencies": {
"webpack": "^4.44.1",
"webpack-cli": "^3.3.12"
}
}
PS我不使用任何模块方法three-legacyjsonloader
,我只是连接
尝试添加
在你的
webpack.config
使用ObjectLoader()加载
.json