I am applying my babylon on previously published React project, but it’s getting this error message.
VM1505:1 Uncaught SyntaxError: Unexpected token < in JSON at position 0
at JSON.parse (<anonymous>)
at e._parseJson (glTFFileLoader.js:875)
at glTFFileLoader.js:521
at XMLHttpRequest.i (fileTools.js:435)
I have included my .gltf model related files in the public folder and it works fine when I run it on local server, but it’s getting this error message on published project.
I get there’s something wrong with the path, but how can I fix it??
I don’t get how this works on local server, but not work on the published project
I am using assetManager for loading.
this.assetLoader = new AssetsManager(this.scene);
loadProductModel(name, src, fileName) {
const meshTask = this.assetLoader.addMeshTask(`${name}Task`, "", src, fileName);
meshTask.onSuccess = function (task) {
task.loadedMeshes[0].position = new Vector3(0, -10, 0);
}
this.assetLoader.load();
This is usually happening why you didn’t include the gltf loader package in your project. Can you make sure that the loaders plugin is included in your project (with the same version as the core package)
Well, it’s your server Can’t really help there.
You should check that the URL is correct and that the file is there, and that the server knows that a gltf should return the correct file type.