How to export Path3D object to .ply file

Hello,
First of all, thanks for making such a wonderful tool! I am new to Babylonjs and trying to apply it to my project.
I am trying to download/upload my Path3D object to local machine/cloud as a .ply format file. Looked into documentation on saving scene/mesh but it doesn’t seem to work with Path3D object.

const exportbtn = (
    <Btn
      style={{ display: markers.length < 3 ? "none" : null }}
      label="Export"
      onClick={async () => {
        const serializedMargin = SceneSerializer.Serialize(path);
        uploadHandler(serializedMargin);
        console.debug("This called?");
        const coordinates = path.map((vec) => `${vec.x} ${vec.y} ${vec.z}`);
        await save(coordinates.join("\n"), "margin.txt");
      }}
    />

I do something like above, where path is a Path3D object. And I get error saying

Uncaught (in promise) TypeError: scene.getEngine is not a function at SceneSerializer._Serialize (sceneSerializer.ts:127:1)

Hello, could you repro in the playground so that we can try to understand what is wrong ?

The first thing I can notice is that you use serialize(path) but only a scene can be serialized with the scene serializer.

2 Likes

Thanks for such a quick response @sebavan !

Yea, like you said, seems like Serializing Path3D is messing up.
Actually, I solved the issue by taking different route. Converted point coordinates of Path3D into csv formatted string (x,y,z\n...). Seems to work fine for me so far!

1 Like