This project is a Babylon.js application that allows users to draw arbitrary 2D shapes on a ground plane, extrude them into 3D objects, and manipulate those objects by moving them and editing their vertices.
- Draw 2D shapes on a ground plane
- Extrude 2D shapes into 3D objects (pyramids for triangles, cuboids for quadrilaterals)
- Move extruded objects on the ground plane
- Edit vertices of extruded objects in 3D space
- Visual mode indicators and object selection feedback
- Clone this repository
- Navigate to the project directory
- Run
npm installto install dependencies
- Run
npm startto start the development server - Open a web browser and navigate to
http://localhost:8080(or the port specified in your console)
- Draw Mode: Left-click to add points, right-click to complete the shape
- Move Mode: Click and drag objects to move them on the ground plane
- Vertex Edit Mode: Click and drag vertices to modify object shapes
The application is built using TypeScript and Babylon.js. The main App class handles the core functionality:
constructor: Sets up the Babylon.js scene, camera, and event listenerscreateGround: Creates the ground plane for drawingaddEventListeners: Sets up user interaction handlerssetMode: Switches between different interaction modesonPointerDown,onPointerMove,onPointerUp: Handle user input for drawing, moving, and editingextrudeShape: Creates 3D objects from 2D shapescreatePyramid,createCuboid: Generate 3D meshes based on user inputupdateVertex: Modifies vertex positions during editing
Basic styling is applied to the canvas and UI elements to improve visual presentation. The styles.css file contains these styles.
- Add support for more complex shapes
- Implement undo/redo functionality
- Add texture mapping capabilities
- Optimize performance for larger scenes
- Babylon.js
- TypeScript
- Webpack (for bundling)