Importing Gaussian splat files as base64 string

Hello!

I am trying to import local .splat/.sog/.ply etc. files as base64 strings, but browsedFile.type reads "" (empty string) and the following error occurs:

Unable to load from data:;base64,...(long base64)...
at errorHandler (sceneLoader.js:400:42)
    at Object.importMesh (babylonFileLoader.js:913:17)
    at eval (sceneLoader.js:439:31)
    at dataCallback (sceneLoader.js:231:13)
    at LoadFile (fileTools.js:435:13)
    at Scene._loadFile (scene.js:5080:86)
    at manifestChecked (sceneLoader.js:256:25)
    at eval (sceneLoader.js:276:13)
    at getPluginInstance (sceneLoader.js:190:13)
    at loadDataAsync (sceneLoader.js:194:12)
    at importMeshAsync (sceneLoader.js:430:18)
    at eval (sceneLoader.js:464:13)
    at new Promise (<anonymous>)
    at importMeshAsyncCoreAsync (sceneLoader.js:462:18)
    at SceneLoader.ImportMeshAsync (sceneLoader.js:980:22)

when executing

...
import "@babylonjs/loaders/SPLAT";
...
import { SceneLoader } from "@babylonjs/core/Loading/sceneLoader";
...
const meshes = "";
const result = await SceneLoader.ImportMeshAsync(
  meshes,
  base64str, // works fine with URLs i.e. "https://raw.githubusercontent.com/CedricGuillemet/dump/master/Halo_Believe.splat",
  file,
  this.scene);

My app is importing Babylon JS

I tried adding application/json to base64 header, which did not work.

I’ll be grateful for any help.

Thank you!

The base64 string must be passed as the sceneFileName parameter, not rootUrl. Also, you have to tell ImportMeshAsync which plugin to use to decode the string, by passing “.splat” for the pluginExtension parameter:

https://playground.babylonjs.com/?inspectorv2=true#CID4NN#366

2 Likes