Overview
TheViewer component is the main entry point for rendering 3D building models in Pascal. It sets up a complete WebGPU rendering pipeline with advanced post-processing, camera controls, lighting, and integration with the Pascal scene graph.
Import
Props
Additional React Three Fiber components to render inside the Canvas. Use this to add custom 3D objects, effects, or controls to the scene.
Controls whether to use the built-in selection manager or provide a custom one.
'default'- Uses the built-inSelectionManagercomponent that handles click and hover interactions'custom'- Disables the default selection manager, allowing you to implement custom selection logic
Basic Usage
Custom Selection Manager
If you need custom selection behavior, you can disable the default selection manager:Adding Custom 3D Content
You can add custom Three.js objects or React Three Fiber components as children:Rendering Pipeline
The Viewer component sets up a complete rendering pipeline:1. WebGPU Renderer
- Tone Mapping: ACES Filmic tone mapping
- Exposure: 0.9
- Shadows: PCF shadow maps enabled
- DPR: 1.0 to 1.5 (device pixel ratio)
2. Default Camera
- Type: Perspective camera (switchable to orthographic via
useViewer) - Initial Position:
[50, 50, 50] - Field of View: 50 degrees
- Controls: Orbit controls with auto-rotation support
3. Lighting System
The viewer includes a sophisticated lighting setup:- Directional lights for sun simulation
- Ambient lighting
- Shadow casting enabled
- Dynamic theme-based adjustments
4. Post-Processing Effects
Advanced post-processing pipeline includes:- SSGI (Screen Space Global Illumination) - Realistic ambient occlusion and indirect lighting
- TRAA (Temporal Reprojection Anti-Aliasing) - Smooth anti-aliased edges
- Outline Rendering - Visual feedback for selection and hover states
- MRT (Multiple Render Targets) - Efficient multi-pass rendering
src/components/viewer/post-processing.tsx:28.
Built-in Systems
The Viewer automatically includes all Pascal rendering systems:Core Building Systems
WallSystem- Wall rendering with cutaway modesCeilingSystem- Ceiling renderingDoorSystem- Door renderingWindowSystem- Window renderingRoofSystem- Roof renderingSlabSystem- Floor slab renderingItemSystem- Furniture and items
Additional Systems
LevelSystem- Multi-level management (stacked/exploded/solo modes)ZoneSystem- Zone boundary renderingGuideSystem- Construction guides and measurementsScanSystem- Point cloud and scan dataWallCutout- Automatic cutouts for doors/windows
Visual Enhancements
GroundOccluder- Ground plane occlusionLights- Dynamic lighting systemPostProcessing- Advanced effects pipelineSelectionManager- Click and hover interaction (when enabled)Bvh- Bounding Volume Hierarchy for optimized raycasting
Theme Support
The viewer supports light and dark themes, controlled via theuseViewer store:
- Light mode:
#ffffff(white) - Dark mode:
#1f2433(dark blue-gray)
Performance Optimization
The Viewer is optimized for performance:- BVH Acceleration - All scene objects are wrapped in a BVH for fast raycasting
- Frustum Culling - Automatic culling of off-screen objects
- Instanced Rendering - Efficient rendering of repeated geometries
- Texture Optimization - Compressed textures for faster loading
- Level of Detail - Automatic LOD based on camera distance (system-dependent)
Complete Example
Related
- useViewer Hook - State management for viewer
- @pascal-app/core - Core scene graph and node types