Module parse failed: Unexpected token (2:12)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
我找了很多文档,实在也是没找到很好的解决方式,后来偶尔从一篇文档中误打误撞找到一个思路,有一个线上查看模型的网址: https://gltf.report/
在这里查看模型后:
点击 Export 按钮后可以再次下载为 .glb 格式文档,这个格式的模型还是也可以用
const loaderGltf = new GLTFLoader(); 方式加载模型
const loaderGltf = new GLTFLoader();
loaderGltf.load('/model/car.glb', (gltf: any) => {
// 这个就是获取到的模型
const mesh = gltf.scene;
});
这里加载模型地址时,一种可以将模型放入 public 下 写绝对路径,
或者 import 引入
import car13 from ‘@/components/models/car.glb’;