I developed a viewer that allows browsing 3D Gaussian Splatting (3DGS) files in the browser. This article explains an overview of 3DGS, why a regular PLY Viewer cannot display it, and the implementation of a dedicated viewer.

Demo:

https://3dtiles-viewer.vercel.app/3dgs-viewer.html?manifest=https://3dtiles-viewer.vercel.app/iiif/ply/manifest.json

Why a Regular PLY Viewer Cannot Display 3DGS

Since 3DGS files have the .ply extension, they appear to be handled the same way as regular PLY files. However, they are not displayed correctly when loaded with Three.js’s PLYLoader.

Differences Between Regular PLY Files and 3DGS PLY Files

Regular PLY (Mesh/Point Cloud):

eppppppeplrrrrrrlreooooooeomppppppmpeeeeeeeeenrrrrrrnrtttttttttyyyyyyyvfefffuuualrlllccccitooohhheseaaaaaatxtttrrr50u1xyzrgb0c0erlh0deua0eernintvertex_indices

3DGS PLY:

epppppppppppppplrrrrrrrrrrrrrreoooooooooooooomppppppppppppppeeeeeeeeeeeeeeenrrrrrrrrrrrrrrtttttttttttttttyyyyyyyyyyyyyyveffffffffffffffrlllllllllllllltooooooooooooooeaaaaaaaaaaaaaaxtttttttttttttt1xyzfffosssrrrr4___pcccoooo2dddaaaatttt0cccclll____0___ieee01230012t___y012####SOSRppcohaateclarietiticy(oaenlll(hiqapursamotoiendrincsisiozn(e)c)olor)

What Happens When Loaded with PLYLoader

Three.js’s PLYLoader cannot understand 3DGS-specific properties. Loading results in the following problems:

  1. Missing color information: f_dc_0, f_dc_1, f_dc_2 are spherical harmonic function coefficients, not RGB colors, so correct colors are not displayed
  2. Displayed as simple point cloud: The shape of each Gaussian (scale/rotation) is ignored and displayed as mere points
  3. Reduced rendering quality: The smooth interpolation characteristic of Gaussian splatting is not performed

Why a Dedicated Renderer Is Needed

To correctly display 3DGS, the following processing is required:

  1. Depth sorting: Sort all Gaussians by distance from the viewpoint (every frame)
  2. 2D projection: Project 3D Gaussians to 2D ellipses
  3. Alpha blending: Composite from back to front

These need to be efficiently processed in GPU shaders and cannot be handled by regular point cloud/mesh renderers. Therefore, the dedicated library Spark.js was used.

What is 3D Gaussian Splatting?

3D Gaussian Splatting (3DGS) is an innovative 3D representation technique presented at SIGGRAPH in 2023. Compared to conventional NeRF (Neural Radiance Fields), it enables real-time rendering and efficiently represents high-quality 3D scenes.

Comparison with Conventional Technologies

TechnologyRendering SpeedQualityEditability
MeshVery fastMediumHigh
Point CloudFastLow-MediumHigh
NeRFSlow (seconds)HighLow
3DGSReal-timeHighMedium

How 3DGS Works

3DGS represents a 3D scene as a collection of many “3D Gaussians” (ellipsoid-shaped points).

Each Gaussian has the following parameters:

  • Position: Center coordinates in 3D space
  • Covariance: Shape and orientation of the ellipsoid
  • Opacity: Transparency
  • SH coefficients (Spherical Harmonic coefficients): View-dependent color information

During rendering, these Gaussians are projected (splatted) onto the 2D screen and composited with alpha blending.

Supported File Formats

PLY Format (.ply)

The most common 3DGS format. Both standard PLY and compressed PLY (compressed.ply) are supported.

pfeppppppppppppppelolrrrrrrrrrrrrrrnyreoooooooooooooodmmpppppppppppppp_aeeeeeeeeeeeeeeehtnrrrrrrrrrrrrrretttttttttttttttabyyyyyyyyyyyyyydiveneffffffffffffffrarllllllllllllllrtooooooooooooooyeaaaaaaaaaaaaaa_xttttttttttttttli1xyzfffosssrrrrt4___pcccoooot2dddaaaattttl0cccclll____e0___ieee0123_0012t___ey012ndian1.0

SPLAT Format (.splat)

A lightweight binary format suitable for web delivery.

KSPLAT Format (.ksplat)

An efficient format developed by Kevin Kwok.

SPZ Format (.spz)

A compressed format proposed by Niantic that can significantly reduce file size.

Implementation Details

Libraries Used

LibraryVersionPurpose
Three.js0.170.03D rendering foundation
OrbitControlsBundled with Three.jsCamera controls
Spark.js0.1.103DGS rendering

About Spark.js

Spark.js is a library for handling 3D Gaussian Splatting with Three.js. It uses WebGL shaders to efficiently sort and splat Gaussians.

ic}asmo)wcpnuo};aeoCsrninrrtlPctete:ro.asonsa{tp'gspdelmroldSaoela(pStdsetslpMes.Mpalel:leltas.osaMthp(ghteMlp(.Mse=yr`lehs'o$oshn,g{ah}erpd)awerP;fnsorrdSsgoop)rmmaleida=ss'dt>se@M.;ste{lposoahars(dkc{ejedsnde/evp/rsopgarreks's;.total100}%`);

Using Import Maps

ES Modules are used to load libraries via CDN.

<{}s/c"}sricim"""rpptt@itohhsprrrpttteea>yseerp""/ke::"j=:s"{"dih"emthvptt/optsrsppt:sam/:ra//kpe/""se:>ms.m"s.hhst/htt/phtsrh:er/ee/@es0@p.0a1.r71k07j.0s0.."0d,/e"v,/releases/spark/0.1.10/spark.module.js"

This enables the use of the latest JavaScript module system without build tools.

Automatic Camera Adjustment

After model loading, the camera position is automatically adjusted based on the bounding sphere.

i}fccccc)aa(ooooa;xxcnnnnmccceeusssStPeeeeSssrttterlrnnncHHrtoaatttaeeescrlc.eeelllnpeacseprrreppthnda.o...eeSetimtcsxyzarrpreueaaix..lersrrmt+++ispaageiscot===erorrras.ttanaaahligcssa..dddeeteupprcasiiil.iorhhgoteuuupsomreeeptssseeneerrtya(rt.tnee(p(crt..tcptroyScroer101oappeano...dy&lndmtp555mi(&atioer,,aucteudritsec.rse)acnug;l;th/treeerocm2remedo,)ne5nid;tt;tserSretlapyradl.niabcutoes.ugnf/edroio2mnm,egtSmrrpoayhdd.eeibrluoesu;n/di2n)g;Sphere){

Model Rotation Feature

3DGS files may have different orientations depending on the coordinate system used during creation. Sliders and preset buttons are provided for adjustment.

f}ddduooonrrrc)ccccooou;PuuuttttrxyzrmmmiXYZreeeeo...esnnnnvvvnetttaaatMMMt...slllSaaasgggeuuupttteeeteeelhhhtttRa...EEEo===tPPPlllt.IIIeeeaxyzrmmmt;;;o///eeeitnnnoa111tttnt888BBB(i000yyyxo,,III,nddd.(((ys''',eppptrrrz(eee)ssseee{ttt---dzfeulfpia'pu)'l.)ta.'da)dd.EdavEdevdneEtnvLteiLnsittsLetinesentree(rn'(ec'rlc(il'cickcl'ki,'c,k',=>=>s=es>teRtsoRetotatRtaoittoianot(ni-(o91n08(,00,,0,00,,0)00)));));;

Drag & Drop Implementation

An overlay UI is implemented to allow loading new files via drag and drop even while a file is being loaded.

d}d}o)o)cdi};cci};Durfuofimadmnlseg(res(opnCdantfaltorgtida.uoO.flSybnpvbiepotZeolsldeorde.avyrnlyslte.+ea.e(ra+.ya=nfld;c.dgiadlcdetlyEalE.hevsavdsdessea>[unLsnt0rtiLta0]iLsiLT)nitsir&;gs.tsa&tc.tndeoaesfrnndnfiaetdeelgra(rre(i'(.s'nv'f[dsidi0r(srl]a'ioe.ghbpsneil';ande,mtd'eee)e.rn;m''=a,)>t)c{h{(/=\>.({ply|splat|ksplat|spz)$/i)){

IIIF Support

The viewer supports IIIF Presentation API 3.0 manifests. It extracts and loads 3DGS file URLs from manifests.

{}""""}@tli]cyat""}opbeti]neemyt""}t"lspeti]e:""emyt""}x::"spetbt":"emyo""""M{[:"spditf:a{":"eydyon"S[:"""pr[iec{":::em"fneA["ahe"nn{"{":tts:enAh"tt"ont":p"[,tntM:,"aopo"/cttsdm/aia:eoicot/lditni/"eiuPoe,lfsanx/."g"api]e,mlo"py/},l"a,ep.ic/opmr/emsoednetla.tpiloyn"/,3/context.json"],

Performance Considerations

Pixel Ratio Limitation

GPU load on high-resolution displays is reduced.

renderer.setPixelRatio(Math.min(window.devicePixelRatio,2));

Memory Management

When loading a new model, the previous model is properly disposed of.

epppppppppppppplrrrrrrrrrrrrrreoooooooooooooomppppppppppppppeeeeeeeeeeeeeeenrrrrrrrrrrrrrrtttttttttttttttyyyyyyyyyyyyyyveffffffffffffffrlllllllllllllltooooooooooooooeaaaaaaaaaaaaaaxtttttttttttttt1xyzfffosssrrrr4___pcccoooo2dddaaaatttt0cccclll____0___ieee01230012t___y012####SOSRppcohaateclarietiticy(oaenlll(hiqapursamotoiendrincsisiozn(e)c)olor)

0

Limitations

LimitationDescription
File sizeDepends on browser memory limits (roughly up to several hundred MB)
Number of GaussiansUp to several million (depends on GPU performance)
MobileWorks but large files are not recommended

Future Improvements

  1. LOD support: Switching detail levels based on viewpoint distance
  2. Multiple model support: Displaying multiple 3DGS files simultaneously
  3. Animation: 4D Gaussian Splatting support
  4. Export: Conversion to other formats

References