A React-based 2D layered grid builder for arranging optical cube modules on precise 50mm × 50mm grids. This application allows users to design complex optical systems by placing, rotating, and layering optical components with snap-to-grid functionality.
- 2D Grid Canvas: Precise 50mm grid with snap-to-grid placement
- Part Library: Draggable optical components with search/filter functionality
- Layer Management: Multiple Z-layers for creating 3D-like stacks
- Module Placement: Drag & drop with collision detection and multi-cell support
- Rotation: 90° rotation steps with footprint integrity
- Export/Import: JSON-based scene serialization
- Split-pane Layout: Part library (left), canvas (center), controls (right)
- Property Panel: Context-aware parameter editing
- Toolbar: Grid controls, undo/redo, export/import
- Layer Panel: Add, remove, and switch between layers
- Search: Real-time filtering of available parts
- Grid Snapping: ≤5px accuracy at 100% zoom
- Collision Detection: Prevents overlapping multi-cell modules
- Zoom & Pan: Mouse wheel zoom and drag-to-pan viewport
- Responsive Design: Adapts to different screen sizes
- Frontend: React 18 + TypeScript
- Canvas: React-Konva for 2D rendering
- State Management: Zustand
- Build Tool: Vite
- Styling: CSS3 with responsive design
- Package Manager: npm
- Node.js (v16 or higher)
- npm or yarn
# Clone the repository
git clone https://github.com/openUC2/openUC2-OptiKit.git
# Navigate to the project directory
cd openUC2-OptiKit
# Install dependencies
npm install
# Start the development server
npm run devThe application will be available at http://localhost:5173
# Build the application
npm run build
# Preview the production build
npm run preview- Browse the Part Library on the left
- Use the search box to filter components
- Drag components from the library onto the canvas
- Components will snap to the 50mm grid automatically
- Use the Layer Panel to add new layers
- Switch between layers by clicking on them
- Each layer represents a different Z-level in your optical system
- Delete layers using the × button (minimum 1 layer required)
- Click on any placed component to select it
- View and edit properties in the Property Panel
- Use the rotate button to rotate components in 90° steps
- Delete components using the delete button
- Grid Toggle (#): Show/hide the grid lines
- Snap Toggle (⊞): Enable/disable snap-to-grid
- Zoom: Use mouse wheel to zoom in/out
- Pan: Drag the canvas to pan around
- Export (↓): Save your layout as a JSON file
- Import (↑): Load a previously saved layout
The application includes several pre-defined optical components:
- Basic Cube (1×1): Standard optical cube
- Double Cube (2×1): Extended optical cube
- Quad Cube (2×2): Large optical cube
- Lens (1×1): Optical lens component
- Mirror (1×1): Reflective mirror component
Each component has:
- Unique color coding
- Footprint dimensions
- Configurable parameters
- Rotation capabilities
src/
├── components/ # React components
│ ├── Layout.tsx # Main application layout
│ ├── GridCanvas.tsx # Konva-based grid canvas
│ ├── PartLibrary.tsx # Draggable parts library
│ ├── LayerPanel.tsx # Layer management
│ ├── PropertyPanel.tsx # Property editing
│ └── Toolbar.tsx # Top toolbar
├── stores/ # State management
│ └── appStore.ts # Zustand store
├── types/ # TypeScript types
│ └── index.ts # Application types
└── utils/ # Utility functions
The application uses Zustand for centralized state management, handling:
- Component definitions and placement
- Layer management
- Selection state
- Grid configuration
- Viewport settings
npm run dev- Start development servernpm run build- Build for productionnpm run preview- Preview production buildnpm run lint- Run ESLint
- ESLint configuration for TypeScript and React
- Consistent naming conventions
- Component-based architecture
- Type-safe development with TypeScript
- Annotation Tools: Line, arrow, and text annotations
- Undo/Redo: Command history implementation
- Advanced Export: SVG and PNG export options
- Collaboration: Multi-user editing capabilities
- Performance: Virtual scrolling for large component libraries
- Accessibility: Full keyboard navigation support
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests and linting
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- OpenUC2 community for the optical cube system concept
- React-Konva for excellent 2D canvas capabilities
- Zustand for lightweight state management
