Using GLTFLoader, I successfully imported a model that works flawlessly with npm run dev
. However, when I attempt to build it using npx vite build
, the model file seems inaccessible. The file is located at /public/models/miku_pde.glb.
When running npm run dev: https://i.sstatic.net/30bwz.png
After building: https://i.sstatic.net/IqIuF.png
This snippet of code showcases how I imported the model:
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
let model;
const loader = new GLTFLoader();
const modelPath = "/models/miku_pde.glb";
loader.load(modelPath, (gltf) => {
model = gltf.scene;
model.position.y = -15;
scene.add(model);
});
I was anticipating the model to display properly. I double-checked the path for accuracy, but unfortunately, it continues to fail after the build process.