Skip to content

A React + TypeScript project that captures user strokes, vectorizes them to SVG paths, and extrudes them into 3D using Three.js.

License

Notifications You must be signed in to change notification settings

AlexanderPotiagalov/Sketch3DConverter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

57 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Sketch To 3D

2D to 3D Demo

Draw in 2D, recognize shapes, and instantly extrude them into interactive 3D.

License Last Commit Top Language GitHub Stars

Built with:ย  Next.js React TypeScript Three.js React Konva Tailwind CSS



๐Ÿ“œ Table of Contents

๐Ÿ“– Overview

Sketch to 3D bridges the gap between imagination and creation. It's an innovative web application that transforms your simple 2D sketches into interactive 3D models in real-time. Whether you're a designer prototyping ideas, an educator teaching geometry, or just someone who loves to create, this tool makes 3D modeling accessible to everyone.

๐ŸŒŸ Why Choose Sketch to 3D?

  • ๐Ÿš€ Zero Learning Curve โ€” If you can draw, you can create 3D models
  • โšก Instant Results โ€” See your sketches transform in real-time
  • ๐ŸŒ Browser-Based โ€” No downloads, no installations, just pure creativity
  • ๐ŸŽจ Creative Freedom โ€” From simple shapes to complex polygons
  • ๐Ÿ”ง Developer-Friendly โ€” Clean APIs and extensible architecture
  • ๐ŸŽ“ Educational โ€” Perfect for learning 3D concepts and spatial reasoning

๐Ÿ“ธ UI Screenshots


โœจ Features

๐ŸŽจ Intuitive Drawing Experience

  • Freehand Drawing with natural pen tools
  • Smart Shape Recognition for circles, rectangles, lines, and polygons
  • Responsive Canvas that adapts to any screen size
  • Undo/Redo Support for confident experimentation
  • Pressure Sensitivity for tablets and stylus devices

๐Ÿ”ฎ Real-Time 3D Magic

  • Instant Extrusion from 2D shapes to 3D objects
  • Interactive 3D Scene with orbit controls and lighting
  • Live Preview as you draw
  • Smooth Animations powered by Three.js
  • Multiple Camera Angles for better visualization

๐Ÿ› ๏ธ Professional Tools

  • Clean API with getStrokes(), clearCanvas(), exportImage()
  • Grid System with snap-to-grid functionality
  • Pan & Zoom independent of shape data
  • Memory Management with automatic cleanup
  • Export Options for various 3D formats

๐ŸŽฏ Performance Optimized

  • WebGL Acceleration for smooth 3D rendering
  • Efficient Algorithms for shape recognition
  • Responsive Design across all devices
  • Progressive Enhancement for older browsers
  • Memory Efficient rendering pipeline

๐Ÿ› ๏ธ Tech Stack

Technology Purpose Why We Chose It
Next.js Framework Server-side rendering & optimal performance
React UI Library Component-based architecture & state management
TypeScript Language Type safety & better developer experience
Three.js 3D Engine Powerful WebGL abstraction & 3D capabilities
Konva 2D Canvas High-performance 2D graphics & interactions
Tailwind Styling Utility-first CSS & rapid prototyping

๐Ÿš€ Quick Start

Get up and running in less than 3 minutes:

Prerequisites

  • Node.js 18+ (Latest LTS recommended)
  • npm or yarn package manager
  • Modern browser with WebGL 2.0 support

Installation

# Clone the repository
git clone https://github.com/AlexanderPotiagalov/Sketch3DConverter.git

# Navigate to project directory
cd Sketch3DConverter

# Install dependencies
npm install

# Start development server
npm run dev

๐ŸŽ‰ That's it! Open http://localhost:3000 and start sketching!

Production Build

# Build for production
npm run build

# Start production server
npm start

# Or serve static files
npm run export && npx serve out/

๐Ÿ“ Project Architecture

Our codebase is organized for clarity and maintainability:

โ”œโ”€โ”€ components
โ”‚   โ”œโ”€โ”€ DrawCanvas.tsx        # Konva-based drawing & shape recognition
โ”‚   โ””โ”€โ”€ ThreeView.tsx         # Three.js scene setup & extrusion logic
โ”œโ”€โ”€ pages
โ”‚   โ”œโ”€โ”€ api
โ”‚   โ”‚   โ””โ”€โ”€ vectorize.ts      # Converts strokes/shapes to 3D specs
โ”‚   โ””โ”€โ”€ index.tsx             # Main UI: toolbar, canvas & 3D layers
โ”œโ”€โ”€ utils
โ”‚   โ””โ”€โ”€ ShapeRecognizer.ts    # Stroke โ†’ RecognizedShape algorithm
โ”œโ”€โ”€ public
โ”‚   โ””โ”€โ”€ assets                # Logo, example images, favicons
โ”œโ”€โ”€ styles
โ”‚   โ””โ”€โ”€ globals.css           # Tailwind imports & custom overrides
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ .env.local
โ”œโ”€โ”€ eslint.config.mjs
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ package-lock.json
โ”œโ”€โ”€ tscongif.json
โ”œโ”€โ”€ postcss.config.mjs
โ””โ”€โ”€ next.config.js            # Dynamic imports & SSR config

๐ŸŽฎ Usage Examples

Basic Drawing API

// Get reference to the drawing canvas
const canvasRef = useRef<DrawCanvasRef>(null);

// Clear the canvas
canvasRef.current?.clearCanvas();

// Export current drawing as image
const imageData = canvasRef.current?.exportImage("png", 0.9);

// Get all strokes for processing
const strokes = canvasRef.current?.getStrokes();

// Set drawing mode
canvasRef.current?.setTool("pen" | "eraser" | "select");

Advanced Shape Recognition

import { ShapeRecognizer } from "./utils/ShapeRecognizer";

const recognizer = new ShapeRecognizer({
  tolerance: 0.1,
  minPoints: 5,
  enableSmoothing: true,
});

const shapes = recognizer.analyzeStrokes(strokeData);
// Returns: Array<Circle | Rectangle | Line | Polygon | Ellipse>

// Advanced recognition with confidence scores
const detailedResults = recognizer.analyzeWithConfidence(strokeData);
// Returns: Array<{ type: string, confidence: number, geometry: Shape }>

3D Scene Integration

import { ThreeScene } from "./components/ThreeView";

// Create 3D scene with custom settings
const scene = new ThreeScene({
  antialias: true,
  shadows: true,
  postProcessing: true,
});

// Add shapes to 3D scene
shapes.forEach((shape) => {
  const mesh = scene.addExtrudedShape(shape, {
    depth: 10,
    bevelEnabled: true,
    material: "phong",
  });
});

// Animate the scene
scene.animate(() => {
  // Custom animation logic
  mesh.rotation.y += 0.01;
});

๐Ÿ”ฎ Roadmap & Future Vision

We're always improving and exploring new possibilities:

  • ๐Ÿค– Smarter AI โ€” Enhanced shape recognition and intelligent suggestions
  • ๐ŸŽจ Better Visuals โ€” Support for textures, lighting, and materials
  • ๐Ÿ“ฑ Mobile Friendly โ€” Seamless experience on phones and tablets
  • ๐Ÿ‘ฅ Collaboration โ€” Real-time drawing with friends or teammates
  • ๐Ÿฅฝ Immersive Tech โ€” AR/VR support and 3D printing export options

๐Ÿค Join Our Community

We believe great software is built by great communities:

๐Ÿ’ฌ Get Involved

Discussions Issues Pull Requests Discord

Ways to Contribute

  • ๐Ÿ› Bug Reports โ€” Help us squash those pesky bugs
  • ๐Ÿ’ก Feature Requests โ€” Share your brilliant ideas
  • ๐Ÿ”ง Code Contributions โ€” Submit pull requests
  • ๐Ÿ“š Documentation โ€” Improve our guides and tutorials
  • ๐ŸŽจ Design & UX โ€” Enhance UI/UX and create assets
  • ๐Ÿ—ฃ๏ธ Community Support โ€” Help others in discussions
  • ๐ŸŽ“ Educational Content โ€” Create tutorials and examples

๐Ÿ“„ License & Credits

Sketch to 3D is open source and available under the MIT License.

Built with modern web technologies and a passion for creativity.


๐Ÿ‘จโ€๐Ÿ’ป Created with โค๏ธ by Alexander Potiagalov

Turning sketches into reality, one line at a time.


GitHub Stars GitHub Forks GitHub Watchers Contributors

โญ Star this repo if you found it helpful!

Made with โœจ for creators, by creators

About

A React + TypeScript project that captures user strokes, vectorizes them to SVG paths, and extrudes them into 3D using Three.js.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published