1.0.8 • Published 2 months ago

@baolong281/gsplat v1.0.8

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

gsplat.js

JavaScript Gaussian Splatting library

gsplat.js is an easy-to-use, general-purpose, open-source 3D Gaussian Splatting library, providing functionality similar to three.js but for Gaussian Splatting.

Quick Start

  • Live Viewer Demo: Explore this library in action in the 🤗 Hugging Face demo. Note: May not work on all devices; use Bonsai for the lowest memory requirements.
  • Editor Demo: Try new real-time updates and editing features in the gsplat.js editor.
  • Code Example: Start coding immediately with this jsfiddle example.

Installation

Prerequisites: Ensure your development environment supports ES6 modules.

  1. Set Up a Project: (If not already set up)

    Install Node.js and NPM, then initialize a new project using a module bundler like Vite:

    npm create vite@latest gsplat -- --template vanilla-ts
  2. Test Your Environment:

    cd gsplat
    npm install
    npm run dev
  3. Install gsplat.js:

    npm install --save gsplat

Usage

Creating a Scene

  • Import gsplat.js components and set up a basic scene.
  • Load Gaussian Splatting data and start a rendering loop.

(in src/main.ts if you followed the Vite setup)

import * as SPLAT from "gsplat";

const scene = new SPLAT.Scene();
const camera = new SPLAT.Camera();
const renderer = new SPLAT.WebGLRenderer();
const controls = new SPLAT.OrbitControls(camera, renderer.canvas);

async function main() {
    const url = "https://huggingface.co/datasets/dylanebert/3dgs/resolve/main/bonsai/bonsai-7k.splat";

    await SPLAT.Loader.LoadAsync(url, scene, () => {});

    const frame = () => {
        controls.update();
        renderer.render(scene, camera);

        requestAnimationFrame(frame);
    };

    requestAnimationFrame(frame);
}

main();

This script sets up a basic scene with Gaussian Splatting data loaded from URL and starts a rendering loop.

FAQ

Q: Can I use .ply files?

A: Yes, gsplat.js supports .ply files. See the ply-converter example for details on how to convert .ply to .splat. Alternatively, convert PLY files from URL in this jsfiddle example.

Q: What are .splat files?

A: .splat files are a compact form of the splat data, offering quicker loading times than .ply files. They consist of a raw Uint8Array buffer.

⚠️ The .splat format does not contain SH coefficients, so colors are not view-dependent.

Q: Can I convert .splat files to .ply?

A: Yes, see the commented code in the ply-converter example. Alternatively, convert .splat to .ply from URL in this jsfiddle example.

⚠️ When converting .ply -> .splat -> .ply, SH coefficients will be lost.

License

This project is released under the MIT license. It is built upon several other open-source projects:

Please note that the license of the original 3D Gaussian Splatting research project is non-commercial. While this library provides an open-source rendering implementation, users should consider the source of the splat data separately.

Contact

Feel free to open issues, join the Hugging Face Discord, or email me directly at dylan@huggingface.co.

acornacorn-jsxajvansi-escapesansi-regexansi-stylesanymatchargparsearray-unionbabel-jestbabel-plugin-istanbulbabel-plugin-jest-hoistbabel-preset-current-node-syntaxbabel-preset-jestbalanced-matchbig-integerbplist-parserbrace-expansionbracesbrowserslistbs-loggerbserbuffer-frombuiltin-modulesbundle-namecallsitescamelcasecaniuse-litechalkchar-regexci-infocjs-module-lexercliuicocollect-v8-coveragecolor-convertcolor-namecommandercommondirconcat-mapconvert-source-mapcreate-jestcross-spawndebugdedentdeep-isdeepmergedefault-browserdefault-browser-iddefine-lazy-propdetect-newlinediff-sequencesdir-globdoctrineelectron-to-chromiumemitteryemoji-regexerror-exescaladeescape-string-regexpeslint-scopeeslint-visitor-keysespreeesprimaesqueryesrecurseestraverseestree-walkeresutilsexecaexitexpectfast-deep-equalfast-difffast-globfast-json-stable-stringifyfast-levenshteinfastqfb-watchmanfile-entry-cachefill-rangefind-upflat-cacheflattedfs.realpathfseventsfunction-bindgensyncget-caller-fileget-package-typeget-streamglobglob-parentglobalsglobbygraceful-fsgraphemerhas-flaghasownhtml-escaperhuman-signalsignoreimport-freshimport-localimurmurhashinflightinheritsis-arrayishis-builtin-moduleis-core-moduleis-dockeris-extglobis-fullwidth-code-pointis-generator-fnis-globis-inside-containeris-moduleis-numberis-path-insideis-referenceis-streamis-wslisexeistanbul-lib-coverageistanbul-lib-instrumentistanbul-lib-reportistanbul-lib-source-mapsistanbul-reportsjest-changed-filesjest-circusjest-clijest-configjest-diffjest-docblockjest-eachjest-environment-nodejest-get-typejest-haste-mapjest-leak-detectorjest-matcher-utilsjest-message-utiljest-mockjest-pnp-resolverjest-regex-utiljest-resolvejest-resolve-dependenciesjest-runnerjest-runtimejest-snapshotjest-utiljest-validatejest-watcherjest-workerjs-tokensjs-yamljsescjson-bufferjson-parse-even-better-errorsjson-schema-traversejson-stable-stringify-without-jsonifyjson5keyvkleurlevenlevnlines-and-columnslocate-pathlodash.memoizelodash.mergelru-cachemagic-stringmake-dirmake-errormakeerrormerge-streammerge2micromatchmimic-fnminimatchmsnatural-comparenode-int64node-releasesnormalize-pathnpm-run-pathonceonetimeopenoptionatorp-limitp-locatep-tryparent-moduleparse-jsonpath-existspath-is-absolutepath-keypath-parsepath-typepicocolorspicomatchpiratespkg-dirprelude-lsprettier-linter-helperspretty-formatpromptspunycodepure-randqueue-microtaskrandombytesreact-isrequire-directoryresolveresolve-cwdresolve-fromresolve.exportsreusifyrimrafrun-applescriptrun-parallelsafe-buffersemverserialize-javascriptshebang-commandshebang-regexsignal-exitsisteransislashsmobsource-mapsource-map-supportsprintf-jsstack-utilsstring-lengthstring-widthstrip-ansistrip-bomstrip-final-newlinestrip-json-commentssupports-colorsupports-preserve-symlinks-flagsynckittersertest-excludetext-tabletitleizetmplto-fast-propertiesto-regex-rangets-api-utilstslibtype-checktype-detecttype-festundici-typesuntildifyupdate-browserslist-dburi-jsv8-to-istanbulwalkerwhichwrap-ansiwrappywrite-file-atomicy18nyallistyargsyargs-parseryocto-queue
1.0.8

2 months ago

1.0.7

2 months ago

1.0.6

2 months ago