3d-mesh-lib
v3.2.0
Published
A comprehensive, production-ready 3D mesh manipulation library for creating 3D editors, modelers, and CAD applications
Maintainers
Readme
3D Mesh Library - As Easy as Three.js!
The 3D Mesh Library - Making 3D mesh operations as easy as Three.js!
A powerful, TypeScript-first 3D mesh manipulation library that makes complex 3D operations as simple as Three.js. Build 3D applications, games, and tools with minimal code.
Quick Start
TypeScript:
import { createCube, createSphere, scale, translate } from '3d-mesh-lib';
// Create shapes
const cube = createCube(1);
const sphere = createSphere({ radius: 0.5 });
// Transform them
const bigCube = scale(cube, 2);
const movedSphere = translate(sphere, { x: 5, y: 0, z: 0 });JavaScript:
const { createCube, createSphere, scale, translate } = require('3d-mesh-lib/js');
// Create shapes
const cube = createCube(1);
const sphere = createSphere({ radius: 0.5 });
// Transform them
const bigCube = scale(cube, 2);
const movedSphere = translate(sphere, { x: 5, y: 0, z: 0 });Features
- Primitives: Create cubes, spheres, planes, cylinders, torus
- Modifiers: Scale, translate, rotate, extrude, mirror
- 3D Editor: Build complete 3D applications in 3 lines
- Asset Pipeline: Texture baking, UV optimization, mesh optimization
- Sculpting: Digital sculpting tools, texture painting, retopology
- File I/O: GLTF, OBJ, STL, JSON, Three.js integration
- Performance: GPU-friendly data structures, spatial partitioning
Installation
npm install 3d-mesh-libBasic Usage
Creating Shapes
TypeScript:
import { createCube, createSphere, createPlane } from '3d-mesh-lib';
const cube = createCube(1); // 1x1x1 cube
const sphere = createSphere({ radius: 0.5, segments: 16 });
const plane = createPlane(2, 2); // 2x2 planeJavaScript:
const { createCube, createSphere, createPlane } = require('3d-mesh-lib/js');
const cube = createCube(1); // 1x1x1 cube
const sphere = createSphere({ radius: 0.5, segments: 16 });
const plane = createPlane(2, 2); // 2x2 planeTransforming Meshes
TypeScript:
import { scale, translate, rotate, extrude } from '3d-mesh-lib';
// Scale a cube
const bigCube = scale(cube, 2);
// Move a sphere
const movedSphere = translate(sphere, { x: 5, y: 0, z: 0 });
// Rotate a plane
const rotatedPlane = rotate(plane, { x: 0, y: Math.PI/4, z: 0 });
// Extrude a plane
const extrudedPlane = extrude(plane, 1);JavaScript:
const { scale, translate, rotate, extrude } = require('3d-mesh-lib/js');
// Scale a cube
const bigCube = scale(cube, 2);
// Move a sphere
const movedSphere = translate(sphere, { x: 5, y: 0, z: 0 });
// Rotate a plane
const rotatedPlane = rotate(plane, { x: 0, y: Math.PI/4, z: 0 });
// Extrude a plane
const extrudedPlane = extrude(plane, 1);Advanced Operations
import { subdivide, center, computeBoundingBox, validateMesh } from '3d-mesh-lib';
// Subdivide a mesh
const highResMesh = subdivide(mesh, 2);
// Center a mesh
const centeredMesh = center(mesh);
// Get bounding box
const bounds = computeBoundingBox(mesh);
// Validate mesh integrity
const isValid = validateMesh(mesh);Build 3D Applications in 3 Lines!
The library includes QuickBuilder - an ultra-simple way to build complete 3D applications:
3D Modeler (3 Lines!)
TypeScript:
import { QuickBuilder } from '3d-mesh-lib';
const builder = new QuickBuilder();
const modeler = builder.buildModeler(); // 3D modeler ready!JavaScript:
const { QuickBuilder } = require('3d-mesh-lib/js/builder');
const builder = new QuickBuilder();
const modeler = builder.buildModeler(); // 3D modeler ready!3D Level Editor (3 Lines!)
const builder = new QuickBuilder();
const levelEditor = builder.buildLevelEditor(); // Level editor ready!3D Game World (3 Lines!)
const builder = new QuickBuilder();
const gameWorld = builder.buildGameWorld(); // Game world ready!3D Architecture (3 Lines!)
const builder = new QuickBuilder();
const architecture = builder.buildArchitecture(); // Architectural scene ready!3D Character Creator (3 Lines!)
const builder = new QuickBuilder();
const characterCreator = builder.buildCharacterCreator(); // Character creator ready!3D Vehicle Designer (3 Lines!)
const builder = new QuickBuilder();
const vehicleDesigner = builder.buildVehicleDesigner(); // Vehicle designer ready!Custom 3D Scene (3 Lines!)
const builder = new QuickBuilder();
const customScene = builder.buildCustomScene([
{ mesh: createCube(2), name: 'MyCube', position: { x: 0, y: 1, z: 0 } },
{ mesh: createSphere({ radius: 1 }), name: 'MySphere' }
]); // Custom scene ready!Advanced Editor Features
Each built application includes:
- Object Management - Add, remove, select objects
- Transformations - Move, rotate, scale objects
- Camera Control - Orbit, pan, zoom camera
- Lighting System - Add, remove, configure lights
- Undo/Redo - Never lose your work
- Scene Statistics - Get detailed scene info
- Export/Import - Save and load scenes
API Comparison: Three.js vs 3D Mesh Library
| Feature | Three.js | 3D Mesh Library |
|---------|----------|------------------|
| Setup | new THREE.Scene() | new QuickBuilder() |
| Create Cube | new THREE.BoxGeometry() | createCube(1) |
| Transform | mesh.position.set(x,y,z) | translate(mesh, {x,y,z}) |
| 3D App | 50+ lines | 3 lines |
Import Options
The library supports multiple import styles for maximum flexibility:
JavaScript Support
100% JavaScript Support - No TypeScript Required!
The library works perfectly with pure JavaScript. All features are available through JavaScript files:
// Pure JavaScript - no TypeScript compilation needed!
const { createCube, scale } = require('3d-mesh-lib/js');
const { lib } = require('3d-mesh-lib/js/one-liner');
const { QuickBuilder } = require('3d-mesh-lib/js/builder');
// Create and transform meshes
const cube = createCube(1);
const bigCube = scale(cube, 2);
const editor = new QuickBuilder().buildModeler();JavaScript Import Paths:
3d-mesh-lib/js- Main JavaScript entry point3d-mesh-lib/js/easy- Easy imports for JavaScript3d-mesh-lib/js/one-liner- One-liner imports for JavaScript3d-mesh-lib/js/editor- 3D Editor for JavaScript3d-mesh-lib/js/builder- QuickBuilder for JavaScript
Perfect for:
- Node.js applications
- Browser scripts (with bundler)
- JavaScript-only projects
- Quick prototyping
- Learning 3D graphics
Option 1: Standard Import
TypeScript:
import { createCube, createSphere, scale } from '3d-mesh-lib';JavaScript:
const { createCube, createSphere, scale } = require('3d-mesh-lib/js');Option 2: One-Liner Import (Recommended)
TypeScript:
import { lib } from '3d-mesh-lib/one-liner';
const cube = lib.cube(1);
const sphere = lib.sphere({ radius: 0.5 });JavaScript:
const { lib } = require('3d-mesh-lib/js/one-liner');
const cube = lib.cube(1);
const sphere = lib.sphere({ radius: 0.5 });Option 3: Easy Imports
TypeScript:
import { primitives, modifiers } from '3d-mesh-lib/easy';
const cube = primitives.cube(1);
const scaledCube = modifiers.scale(cube, 2);JavaScript:
const { primitives, modifiers } = require('3d-mesh-lib/js/easy');
const cube = primitives.cube(1);
const scaledCube = modifiers.scale(cube, 2);Option 4: Category Imports
import { QuickBuilder } from '3d-mesh-lib/builder';
import { TextureBaker } from '3d-mesh-lib/assets';Examples
Check out the examples/ folder for complete working examples:
simple-usage.ts- Basic library usagebuild-3d-apps.ts- Building 3D applicationsimport-options.ts- All import stylessculpting-digital-art.ts- Digital sculptingasset-pipeline-example.ts- Asset pipeline
Documentation
API_REFERENCE.md- Complete API documentationARCHITECTURE.md- Library architecture and designEXAMPLES.md- Detailed examples and tutorialsGEOMETRY_OPERATIONS.md- Geometry operation details
Contributing
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
License
MIT License - see LICENSE file for details.
The 3D Mesh Library makes building 3D applications extremely simple!
