$ show reall3d-com/Reall3dViewer
Reall3dViewer is a high-performance 3D Gaussian Splatting (3DGS) web viewer built on Three.js. It streams and renders large-scale point cloud scenes (up to 150M points) at interactive frame rates across desktop and mobile devices. The viewer supports multiple input formats including PLY, SPLAT, SPX (proprietary high-compression format), SPZ, SOG, and GLB with the KHR_gaussian_splatting extension. Its architecture is event-driven and modular, with a central event system (Events.ts), dedicated loaders for each format, web workers for parallel data fetching and sorting, and a texture management pipeline that handles LOD tile streaming, frustum culling, and adaptive quality levels. Beyond basic viewing, the repository provides a full suite of interactive features: measurement and annotation tools (distance, area, point labels, 3D tags, circle plans), a map viewer (Reall3dMapViewer) with GIS basemap integration, a first-person/third-person player mode with physics (rapier3d), weather effects (rain, snow), audio-driven text overlays, and a fly-through camera path system. The code is published as an npm package (@reall3d/reall3dviewer) and includes comprehensive demo pages with scene configuration JSON files. While primarily an application library, the project also exhibits data/research characteristics through its custom SPX format specifications, advanced compression techniques (WebP, gzip, xz, zstd), and spherical harmonics support up to degree 3. The source code demonstrates high engineering craftsmanship in areas like GLSL shader modularization, WebAssembly integration for format parsing, and efficient web worker communication patterns. However, there are some maintenance risks including a large monolithic event constant file (200+ auto-incremented integers), hardcoded demo URLs, and a build script that embeds worker code as base64, which complicates debugging. No automated tests are present.
The LLM identified 6 files worth highlighting for reuse:
A lightweight, generic event system supporting single and multi-listener modes. It provides typed events with callbacks and is used as the central communication backbone across all viewer subsystems. The implementation is clean, has no external dependencies, and can be extracted into any JavaScript/TypeScript project requiring a decoupled event bus.
Sets up a Web Worker for parallel downloading and parsing of model data. The worker code is embedded as a base64 string during build (via buildPkg.js), enabling a single-file distribution. This pattern of bundling worker logic into the main bundle is reusable for any project needing concurrent data fetching without separate worker files.
The core splat mesh component that manages the entire lifecycle of a Gaussian splat scene: loading, rendering, LOD switching, and disposal. It integrates with the texture manager, shader generation, and event system. While tightly coupled to the viewer's data structures, its lifecycle pattern (options, load, update, dispose) and event-driven state management are architecturally clean and demonstrate solid component design.
Extends Three.js OrbitControls with additional configuration methods (updateByOptions, updateRotateAxis, etc.) and integrates with the viewer's event system. It demonstrates a reusable pattern for wrapping third-party controls with custom options and event hooks, making it easy to adapt to other Three.js applications.
A 3D annotation tag that extends Three.js Group with methods for drawUpdate, drawFinish, getMarkData, and dispose. It represents a point-based label with customizable appearance and is part of a family of mark classes (MarkSinglePoint, MarkDistanceLine, etc.) that share a common interface. This component is self-contained and can be reused in any Three.js scene requiring interactive 3D labels.
The shader chunk directory contains modular GLSL files (Chunk0VarDeclarations.glsl, Chunk5SpaltLod.glsl, Chunk9AnimateParticle.glsl, etc.) that are composed via #include directives. This pattern of splitting shader logic into reusable, separately-compilable chunks is a best practice for complex GPU programs and can be adopted by any WebGL/Three.js project requiring maintainable shader code.