0

I use Three.js in a Gridsome projet, but I'm unable to import .glb file (3D model) with GLTFLoader. Gridsome considers img (png/jpg) or .js files stored in src/assets but not glb.

My files hierarchy :

enter image description here

My import function :

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

I receive a 404 error when loading the file.

Any idea ?

Thibault Walterspieler
  • 2,272
  • 2
  • 15
  • 25

1 Answers1

0

Use the /static directory of Gridsome and rebuild your project All files in this directory will be copied directly to your dist during build.

After you can change your import function to :

this.loader.load('./nameOfYourModel.glb', function(gltf) {
  // Your code here 
});
Thibault Walterspieler
  • 2,272
  • 2
  • 15
  • 25