【问题标题】:Use .GLB / Blender files in Gridsome project (Vue.js)在 Gridsome 项目 (Vue.js) 中使用 .GLB / Blender 文件
【发布时间】:2021-01-21 08:34:03
【问题描述】:

我在 Gridsome 项目中使用 Three.js,但无法使用 GLTFLoader 导入 .glb 文件(3D 模型)。 Gridsome 考虑存储在 src/assets 中的 img (png/jpg) 或 .js 文件,但不考虑 glb。

我的文件层次结构:

我的导入功能:

this.loader.load('../assets/models/mars.glb', function(gltf) {
  let scale = 5.6;
});

加载文件时收到 404 错误。

有什么想法吗?

【问题讨论】:

    标签: javascript vue.js three.js blender gridsome


    【解决方案1】:

    使用 Gridsome 的 the /static directory 并重新构建您的项目 此目录中的所有文件将在构建期间直接复制到您的 dist。

    您可以将导入功能更改为:

    this.loader.load('./nameOfYourModel.glb', function(gltf) {
      // Your code here 
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-01-05
      • 2020-04-09
      • 1970-01-01
      • 2019-06-08
      • 1970-01-01
      • 2020-02-10
      • 1970-01-01
      • 2017-10-12
      相关资源
      最近更新 更多