Independent, reusable modules for building 3D viewers with Three.js.
Architecture Overview
The library follows a Data-Driven Design pattern, separating state from rendering logic, and uses Dependency Injection for modularity.
Core Components
ThreePresenter: The main controller that orchestrates the 3D scene, manages state, and coordinates other components.
SceneDescription: A pure JSON object defining the scene (models, environment), decoupled from the runtime state.
Subsystems
The functionality is split into specialized managers to avoid a monolithic design:
InputController: Handles all user input (mouse, touch, keyboard) and raycasting. It is decoupled from the presenter and communicates via callbacks.
DefaultUI: A standalone UI overlay that consumes the presenter's state and methods. It demonstrates how to build a UI on top of the library without tight coupling.
RenderLoop: Encapsulates the requestAnimationFrame loop, allowing for efficient rendering control.
Managers: Specialized classes for internal logic:
ModelLoader: Handles loading of heterogenous 3D formats (GLB, PLY, NXS).
LightingManager: Manages scene lighting and environment maps.
CameraManager: Handles camera switching (Persp/Ortho) and controls.
The ThreePresenter constructor accepts a managers object, allowing you to inject custom implementations of core subsystems (like ModelLoader or LightingManager) for testing or customization.
Three Presenter - Modular 3D Viewer Components
Independent, reusable modules for building 3D viewers with Three.js.
Architecture Overview
The library follows a Data-Driven Design pattern, separating state from rendering logic, and uses Dependency Injection for modularity.
Core Components
Subsystems
The functionality is split into specialized managers to avoid a monolithic design:
requestAnimationFrameloop, allowing for efficient rendering control.Dependency Injection
The
ThreePresenterconstructor accepts amanagersobject, allowing you to inject custom implementations of core subsystems (likeModelLoaderorLightingManager) for testing or customization.Example
See