Hi everybody, i struggle around for some simple model importing.
I got a Vue 3/webpack dev env and the only way i could load a glb model is by using a blob and babylons Tools.DecodeBase64().
For example:
import model from â@/assets/models/cube.glbâ;
var base64_model_content = model;
var raw_content = Tools.DecodeBase64(
var blob = new Blob([
var url = URL.createObjectURL(
SceneLoader.Append("", url, this.scene, (
âDo Stuffâ
}, onProgress, onError, â.glbâ);
Also put the models into the public/static folder⌠Seems like the loaders can´t read the local path? Anyone got an idea about what to do so that i can just the assetmanager or sceneloader in a simple way like:
SceneLoader.Append(âmodelNameâ, âpath/to3DModels/â, âmodelName.gltfâ, this.scene, (_newScene) => {});
Thanks a lot.
Hello!
can you tell us what error do you get? How does the network profiler look like (f12)?
Hi and sorry, of course i got some more infoâŚ
When I use the assetmanager:
var meshTask = this.assetsManager.addMeshTask(âtaskâ, ââ, âsrc/assets/models/â, âterrain.glbâ);
I got no console errors, instead i got an html content as response.
If I go with the SceneLoader:
SceneLoader.Append(âsrc/assets/models/plane/â, âP Shooter.glbâ, this.gameScene, function (
// do something with the scene
});
I get: âUnable to load from src/assets/models/plane/P Shooter.glb: Unexpected magic: 1329865020â
What is the content of that html? Probably a 404. Can you check the network profiler when bjs tries to load that file?
Yep seems like 404âŚ
It returns 200 but the file size is for every model 2.1kb⌠so just the html?
So i can imagine that the dev env i use (vue3/webpack) can´t load or resolve the path i need to inject into babylons asset loaders⌠I tried the npm module âgltf-webpack-loaderâ but could not make it work. The only work-around is by adjusting the url-oader of webpack to allow/use â(/.(glb|gltf|bin)$/i)iâ and then decoding the .glb file before loading and using a blob. But with that i only can laod glb´s but no gltf´s and it feels hacky if i got more than one model⌠I have no idea what i could do else. Do you got a solution? thanks
Blob will be the only way of you want to bundle everything
I would recommend to not bundle your gltf assets and let them accessible through a regular url
Hey Deltakosh, thanks a lot for the fast and helpful support.
So I´ll go from here with static assets and absolute paths.
By the way thx for pushing Babylon⌠just get into it and it feels clean and nicely abstracted.
1 Like