How xeokit/xeokit-sdk works
• Viewer Core: At the heart of the system is the Viewer class (located in src/viewer). This component manages the WebGL render loop, handles camera settings (eye, look, up vectors), and coordinates scene updates.
• Plugin System: Surrounding the Viewer core is the plugin architecture. Various loader plugins (such as XKTLoaderPlugin, GLTFLoaderPlugin, LASLoaderPlugin, OBJLoaderPlugin, CityJSONLoaderPlugin, etc.) extend the viewer’s capabilities. Also include other plugins (for annotations, measurements, navigation, section planes, and more). This modular design allows for class-specific responsibilities (e.g., model loading, scene updates or UI interactions).
• Scene Graph & Model Management: This comprises the scene-related modules (present in src/viewer/scene) that include geometry, mesh handling, cameras, lights, materials, and node hierarchies. This layer takes model data supplied by plugins and transforms it into a renderable scene.
• Rendering Pipeline: Within the viewer, the rendering subsystem deals with WebGL resources, shaders, and the frame update loop. It gets its data from the scene graph and issues rendering calls.
• Extras and Utilities: Components like collision detection (src/extras/collision), context menus (src/extras/ContextMenu), plus other UI and helper modules (for example, pointer controls and marquee pickers) help with user interaction and scene manipulation.
Relationships and data flows
• Plugins (e.g., the XKTLoaderPlugin) are responsible for loading external data (like XKT models) and passing parsed scene objects to the scene graph layer.
• The Scene Graph then supplies structured geometry, cameras, lights, etc. to the Rendering Pipeline.
• User input and interaction events (handled by interaction/controls plugins) affect the Viewer core (which updates camera positions and scene state).
• Additionally, utility modules and extras such as collision detection and context menu handling are invoked by both plugins and viewers to provide interactive capabilities.
Architectural design patterns
• Modular and Extensible Plugin Architecture: Emphasize how each plugin is a self-contained module that registers itself with the Viewer.
• Layered Design: Show the separation between the data loading/parsing layer (plugins), the scene graph (model representation), and the rendering layer (WebGL processing).
• Decoupled Event and UI Handling: Reflect that interactive extras (e.g., context menus, pointer controls) are separated from the core rendering but still integrated via callbacks or event handlers.
Technologies and key file groups
• JavaScript (ES Modules) and TypeScript type definitions (in types/) underpin the code.
• Use of build tools (Rollup configurations) and testing frameworks (Playwright, tests/) may be included in a separate “Tooling & DevOps” section.