I created a model in Blender and then exported it to JSON using Three.js official exporter. Then I tried to load it using the next code:
const loader = new THREE.JSONLoader();
loader.load('assets/models/bear.json', (geometry, materials) => {
const bear = new THREE.Mesh(geometry, new THREE.MeshFaceMaterial(materials));
scene.add(bear);
});
Then I got the error:
(unknown) TypeError: url.split is not a function
at Object.extractUrlBase (eval at <anonymous> (app.js:742), <anonymous>:32860:19)
at JSONLoader.load (eval at <anonymous> (app.js:742), <anonymous>:33166:120)
Here is my json file: https://github.com/elliepooh/VRcard/blob/master/src/assets/models/bear.json
I found some decisions, but they all are about renaming the .json file to .js and load it instead. Since I'm using webpack and eslint, it is problematic for some reasons...
I also tried to use Clara.io JSON loader code this way:
const loader = new THREE.ObjectLoader();
loader.load('assets/models/bear.json', (obj) => {
scene.add(obj);
});
And then I got the following TypeError: url.lastIndexOf is not a function
If there any method of loading json to three.js without changing it's file extension and without having such errors? Any help would be appreciated...
bearModelis actually from animport. Have you tried it with just a string, like you have in the code in your post? 2) Which transpiler are you using? Ifimport x from "@...."doesn't return a string, then that's the problem, becauseloader.loadexpects the first parameter to be a valid URL string./assets/models/bear.json. The/at the front references the root of your server (unless your server/framework defines otherwise). Otherwise try a fully qualified URL (http://...etc...) to see if your server is actually replying with the JSON.