# Unable to load gaussian spalt .ply file

**URL:** <https://forum.babylonjs.com/t/unable-to-load-gaussian-spalt-ply-file/47707>\
**Category:** Questions\
**Created:** [January 31, 2024, 9:37pm UTC](https://forum.babylonjs.com/t/unable-to-load-gaussian-spalt-ply-file/47707 "2024-01-31T21:37:55Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![EmberCult](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/embercult/32/22935_2.png) [@EmberCult](https://forum.babylonjs.com/u/EmberCult)\
**Post date:** [January 31, 2024, 9:37pm UTC](https://forum.babylonjs.com/t/unable-to-load-gaussian-spalt-ply-file/47707/1 "2024-01-31T21:37:55Z")

</div>

```auto
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](https://cdn.discordapp.com/attachments/1102954548634595389/1201902905121308713/result.ply)

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [February 1, 2024, 11:03am UTC](https://forum.babylonjs.com/t/unable-to-load-gaussian-spalt-ply-file/47707/2 "2024-02-01T11:03:08Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![EmberCult](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/embercult/32/22935_2.png) [@EmberCult](https://forum.babylonjs.com/u/EmberCult)\
**Post date:** [February 1, 2024, 12:35pm UTC](https://forum.babylonjs.com/t/unable-to-load-gaussian-spalt-ply-file/47707/3 "2024-02-01T12:35:37Z")

</div>

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

> **[Babylon.js Playground](https://playground.babylonjs.com/#CID4NN%231)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [February 1, 2024, 1:32pm UTC](https://forum.babylonjs.com/t/unable-to-load-gaussian-spalt-ply-file/47707/4 "2024-02-01T13:32:51Z")

</div>

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

> **[Babylon.js Playground](https://playground.babylonjs.com/#CID4NN%234)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

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

---

<div class="post-metadata">

**Author:** ![EmberCult](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/embercult/32/22935_2.png) [@EmberCult](https://forum.babylonjs.com/u/EmberCult)\
**Post date:** [February 1, 2024, 1:46pm UTC](https://forum.babylonjs.com/t/unable-to-load-gaussian-spalt-ply-file/47707/5 "2024-02-01T13:46:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [February 1, 2024, 2:16pm UTC](https://forum.babylonjs.com/t/unable-to-load-gaussian-spalt-ply-file/47707/6 "2024-02-01T14:16:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [February 1, 2024, 2:16pm UTC](https://forum.babylonjs.com/t/unable-to-load-gaussian-spalt-ply-file/47707/7 "2024-02-01T14:16:21Z")

</div>

Assigned @Cedric on February 1, 2024, 2:16pm UTC



---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [February 2, 2024, 2:48pm UTC](https://forum.babylonjs.com/t/unable-to-load-gaussian-spalt-ply-file/47707/8 "2024-02-02T14:48:11Z")

</div>

> <https://github.com/BabylonJS/Babylon.js/pull/14761>
>
> Follow up https://forum.babylonjs.com/t/unable-to-load-gaussian-spalt-ply-file/4…7707

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [February 2, 2024, 2:48pm UTC](https://forum.babylonjs.com/t/unable-to-load-gaussian-spalt-ply-file/47707/9 "2024-02-02T14:48:15Z")

</div>

Unassigned @Cedric on February 2, 2024, 2:48pm UTC



---

<div class="post-metadata">

**Author:** ![Don\_Gillett](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/don_gillett/32/38188_2.png) [@Don\_Gillett](https://forum.babylonjs.com/u/Don_Gillett)\
**Post date:** [March 8, 2024, 12:14am UTC](https://forum.babylonjs.com/t/unable-to-load-gaussian-spalt-ply-file/47707/10 "2024-03-08T00:14:08Z")

</div>

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…

```auto
 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.

---

<div class="post-metadata">

**Author:** ![Don\_Gillett](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/don_gillett/32/38188_2.png) [@Don\_Gillett](https://forum.babylonjs.com/u/Don_Gillett)\
**Post date:** [March 8, 2024, 4:40am UTC](https://forum.babylonjs.com/t/unable-to-load-gaussian-spalt-ply-file/47707/11 "2024-03-08T04:40:42Z")

</div>

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.

```auto
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: [],
        };
    }

```

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [March 8, 2024, 10:38am UTC](https://forum.babylonjs.com/t/unable-to-load-gaussian-spalt-ply-file/47707/12 "2024-03-08T10:38:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [March 8, 2024, 10:38am UTC](https://forum.babylonjs.com/t/unable-to-load-gaussian-spalt-ply-file/47707/13 "2024-03-08T10:38:44Z")

</div>

Assigned @Cedric on March 8, 2024, 10:38am UTC



---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [March 8, 2024, 1:38pm UTC](https://forum.babylonjs.com/t/unable-to-load-gaussian-spalt-ply-file/47707/14 "2024-03-08T13:38:39Z")

</div>

Unassigned @Cedric on March 8, 2024, 1:38pm UTC



---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [March 8, 2024, 2:48pm UTC](https://forum.babylonjs.com/t/unable-to-load-gaussian-spalt-ply-file/47707/15 "2024-03-08T14:48:09Z")

</div>

> <https://github.com/BabylonJS/Babylon.js/pull/14852>
>
> follow up https://forum.babylonjs.com/t/unable-to-load-gaussian-spalt-ply-file/4…7707/13
> more explicit error for @thomlucc file test
> update sandbox label
