Hello Dear Community!
I have mesh saved in the .babylon file, and I’m using ImportMeshAsync
. Because of some business limitations, I cannot make any XHR requests from my code.
What would be the best way to transform .babylon file to TypeScript code?.
Maybe relying on base64 or blob urls ?
Hello Dear Community!
Unfortunately, I didn’t figure out how to parse the .babylon file without making an XHR call. Do you have any other ideas?
I found a way!
I took a look a little bit in the source code, and the second argument of ImportSceneAsync can stand as URL to Babylon file or stringified JSON with precedent “data:” prefix.
Here is an example:
SceneLoader.ImportMeshAsync(null, `data: ${CUSTOM_HEMISPHERE_JSON}`).then((result) => {
this.disposeSphere();
this.createSphere(result.meshes[0] as Mesh);
}).catch(() => {
this.options.format = Format.Hemisphere;
this.disposeSphere();
this.createSphere();
});
2 Likes