gsplat.js icon indicating copy to clipboard operation
gsplat.js copied to clipboard

How to start rendering with a local file path?

Open yifanlu0227 opened this issue 1 year ago • 2 comments

Hi, thanks for your work!

I am new to JS and want to ask how to start rendering given a local path. I really appreciate any help you can provide.

yifanlu0227 avatar Mar 18 '24 07:03 yifanlu0227

In the example code, try using LoadFomFileAsync instead of LoadAsync. Instead of an URL, you have to pass a File object.

You can easily find how to upload a file in your browser, and use this File object using LoadFomFileAsync/

engelba avatar Mar 25 '24 11:03 engelba

Assuming your local file is in the data folder of your project, you can use this to load the file:

import * as SPLAT from 'gsplat';

const result = await fetch('/data/your_ply_file.ply');
const blob = await result.blob();
await SPLAT.PLYLoader.LoadFromFileAsync(blob, scene, () => {});

RigoTamas avatar Apr 18 '24 13:04 RigoTamas