Unable to load gaussian spalt .ply file

gaussianSplattingMesh.ts:222 Uncaught (in promise) RangeError: byte length of Float32Array should be a multiple of 4
    at new Float32Array (<anonymous>)
    at t._loadData (gaussianSplattingMesh.ts:222:25)
    at gaussianSplattingMesh.ts:150:18
t._loadData @ gaussianSplattingMesh.ts:222
(anonymous) @ gaussianSplattingMesh.ts:150

Getting this error when trying to load my file
link to my file https://cdn.discordapp.com/attachments/1102954548634595389/1201902905121308713/result.ply

Dropping your file in the sandbox does work, so it must be a problem with your code creating the splat. Can you setup a repro in the Playground?

Im trying to load the ply file directly, I thought that was supported?

Indeed, it is only supported if you use SceneLoader.LoadAsync (which has the disadvantage of creating a new scene):

cc @Cedric to know if it’s possible to also support it when creating a splatting mesh “by hand”.

I see not an issue then, Ill convert the ply to splat in backend itself

It should, there is a crash in the console. I’m taking a look.

1 Like

splatFileLoader.ts has an importMeshAsync signature that only takes in a rootUrl

importMeshAsync(_meshesNames: any, scene: Scene, data: any, rootUrl: string)

It is called from sceneLoader.ts with a signature that has more params

importMeshAsync(meshNames, scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name)

So it appears that it is ignoring the actual filename in code paths where both are passed in. This is the codepath used when utilizing a Model in react-babylonjs which takes the root filename and model filename as independent parameters.

In contrast the glTFFileLoader has an importMeshAsync signature that takes in both parts of the path and it works correctly…

 importMeshAsync: (
        meshesNames: any,
        scene: Scene,
        container: Nullable<AssetContainer>,
        data: IGLTFLoaderData,
        rootUrl: string,
        onProgress?: (event: ISceneLoaderProgressEvent) => void,
        fileName?: string)

As a result Model can load Gltf/Glb files correctly but it can’t load splats.

I was able to fix this by extending importMeshAsync in splatFileLoader.ts to include the other optional parameters from the interface it implements. I just did a simple hack to concat the root path and filename. The correct fix should use some file name utils to properly combine the root and filename, and I don’t fully understand the other cases where root can be passed in without a filename. But this does now work with Model from react-babylonjs. Just pass it a ply or splat file and it loads fine.

public async importMeshAsync(_meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult> {
        const gaussianSplatting = new GaussianSplattingMesh("GaussianSplatting", null, scene);
        await gaussianSplatting.loadFileAsync(rootUrl + fileName); // was just loadFileAsync(rootUrl);
        return {
            meshes: [gaussianSplatting],
            particleSystems: [],
            skeletons: [],
            animationGroups: [],
            transformNodes: [],
            geometries: [],
            lights: [],
            spriteManagers: [],

I’m taking a look. Thanks for reporting @Don_Gillett

1 Like