huggingface / gsplat.js

JavaScript Gaussian Splatting library.
MIT License
1.26k stars 77 forks source link

How to start rendering with a local file path? #76

Open yifanlu0227 opened 3 months ago

yifanlu0227 commented 3 months ago

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.

engelba commented 3 months ago

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/

RigoTamas commented 2 months ago

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, () => {});