# @bitbybit-dev/threejs

[Three.js](https://threejs.org/) engine integration for [Bitbybit](https://bitbybit.dev) - draw and interact with CAD geometry from OCCT, JSCAD, and Manifold kernels directly in your Three.js scenes.

<img src="https://bitbybit.dev/files/site/git-cover.png" alt="Picture showing bitbybit.dev platform">

## Overview

This package connects Bitbybit's powerful CAD kernels to the Three.js rendering engine. It includes `three` as a dependency, so you don't need to install Three.js separately. Create parametric 3D models with professional CAD operations and render them with Three.js's lightweight yet flexible rendering capabilities.

## Quick Start

The fastest way to scaffold a Three.js + Bitbybit project:

```bash
npx @bitbybit-dev/create-app my-project --engine threejs
cd my-project
npm install
npm run dev
```

This creates a complete Vite + TypeScript project with all three CAD kernels (OCCT, JSCAD, Manifold) pre-configured and rendering through Three.js. [Learn more about the CLI](https://learn.bitbybit.dev/learn/npm-packages/intro).

### Need Server-Side CAD?

The CLI first asks you to choose between a **Frontend** app or a **CAD Cloud** app. Select "cloud" to scaffold a full-stack project with a backend (Hono on Cloudflare Workers, Node.js Express, or ASP.NET Core) and a React + Three.js frontend. Your API key stays on the server and the frontend proxies requests through your backend:

```bash
npx @bitbybit-dev/create-app my-cloud-project --type cloud
```

Choose from 5 backend templates: Hono + SDK, Hono + REST, Node.js + SDK, Node.js + REST, or .NET + REST. Each includes ready-to-run examples with model generation, batch operations, and [CAD pipelines](https://learn.bitbybit.dev/api/sdk/typescript/pipelines). [Learn more](https://learn.bitbybit.dev/api/cloud-api).

## Use It With an AI Agent

An agent that does not know an API invents plausible names for it, and Bitbybit has more functions across its three CAD kernels than any model holds in memory. The free **[Bitbybit CAD MCP](https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/mcp/bitbybit-mcp)** server removes the guesswork: your agent looks up the exact signature, parameter defaults, return type and examples for the version of `@bitbybit-dev/threejs` your project has installed, and writes code that compiles the first time.

```bash
claude mcp add --transport http bitbybit https://mcp.bitbybit.dev/mcp
```

Cursor, VS Code, claude.ai, ChatGPT and the Claude API connect to the same endpoint; [`npx -y @bitbybit-dev/mcp`](https://www.npmjs.com/package/@bitbybit-dev/mcp) runs the same server locally, pinned to your installed version. [Every configuration is here](https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/mcp/bitbybit-mcp).

With a [CAD Cloud](https://bitbybit.dev/cad-cloud) key, the [Bitbybit CAD Cloud MCP](https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/mcp/cad-cloud-mcp) goes further and lets the agent run the geometry for you - measure a STEP file, run a pipeline, convert to glTF - and hand back the results as files. For assistants that cannot speak MCP, the whole API is also published as [context files](https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/prompt-contexts). The [AI section of the documentation](https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/intro) explains all of it.

## Learn

| Topic | Link |
|-------|------|
| **Quick Start Tutorial** | https://learn.bitbybit.dev/learn/npm-packages/threejs/start-with-three-js |
| **About Three.js Integration** | https://learn.bitbybit.dev/learn/npm-packages/threejs/about-threejs |
| **Advanced Parametric Model** | https://learn.bitbybit.dev/learn/npm-packages/threejs/advanced-parametric-3d-model |
| **Hex House Concept** | https://learn.bitbybit.dev/learn/npm-packages/threejs/hex-house-concept |
| **Three.js Engine Setup** | https://learn.bitbybit.dev/learn/getting-started/engines/threejs |
| **AI Coding Agents - Overview** | https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/intro |
| **Bitbybit CAD MCP** | https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/mcp/bitbybit-mcp |

## Links

| Resource | URL |
|----------|-----|
| **GitHub** | https://github.com/bitbybit-dev/bitbybit/tree/master/packages/dev/threejs |
| **Monorepo** | https://github.com/bitbybit-dev/bitbybit |
| **NPM** | https://www.npmjs.com/package/@bitbybit-dev/threejs |
| **Documentation** | https://learn.bitbybit.dev/learn/npm-packages/threejs/start-with-three-js |
| **API Reference** | https://docs.bitbybit.dev/modules/Bit |
| **Unit Test Coverage** | https://github.com/bitbybit-dev/bitbybit/actions/workflows/verify.yml |

### API reference

Every class, method and input type in this package is documented in the generated TypeScript API reference:

- [Full API index](https://docs.bitbybit.dev/modules/Bit)
- [Draw](https://docs.bitbybit.dev/classes/Bit.Draw)
- [OCCT](https://docs.bitbybit.dev/classes/Bit.OCCT)
- [Vector](https://docs.bitbybit.dev/classes/Bit.Vector)

## Example Applications

| App | Source Code |
|-----|-------------|
| [Hex Shell](https://learn.bitbybit.dev/learn/npm-packages/threejs/advanced-parametric-3d-model) | [GitHub](https://github.com/bitbybit-dev/bitbybit/tree/master/examples/vite/threejs/hex-shell) |
| [Cup Configurator](https://app-store.bitbybit.dev/cup) | [GitHub](https://github.com/bitbybit-dev/bitbybit/tree/master/examples/vite/threejs/cup) |
| [Hex House Concept](https://learn.bitbybit.dev/learn/npm-packages/threejs/hex-house-concept) | [GitHub](https://github.com/bitbybit-dev/bitbybit/tree/master/examples/vite/threejs/hex-house-concept) |
| [Starter Template](https://github.com/bitbybit-dev/bitbybit/tree/master/examples/vite/threejs/starter-template) | [GitHub](https://github.com/bitbybit-dev/bitbybit/tree/master/examples/vite/threejs/starter-template) |
| [Terrace Furniture](https://app-store.bitbybit.dev/terrace-furniture) (BabylonJS) | Closed source |

## Development

```bash
# Build package
npm run build-p

# Run unit tests with coverage
npm run test:coverage

# Re-run them as you edit
npm run test:watch
```

## Bitbybit Platform

Beyond NPM packages, Bitbybit offers:

- **[Visual Programming Editors](https://bitbybit.dev)** - Rete & Blockly drag-and-drop 3D modeling, plus a Monaco TypeScript editor  
- **[CAD Cloud API](https://learn.bitbybit.dev/api/cloud-api)** - Build full [pipelines](https://learn.bitbybit.dev/api/sdk/typescript/pipelines) that compose all Bitbybit algorithms, where each step can reference outputs of previous steps. Supports parametric model generation, STEP-to-glTF conversion, and complex CAD workflows via HTTP  
- **[Bitbybit Studio](https://studio.bitbybit.dev)** - A growing visual dashboard where API Key users can generate models, convert files, build [pipelines with a GUI](https://learn.bitbybit.dev/api/studio/intro), inspect tasks, and preview 3D results  
- **[3D Bits for Shopify](https://apps.shopify.com/3d-bits-1)** - Interactive 3D product configurators for e-commerce  
- **[Script Runners](https://learn.bitbybit.dev/learn/runners/intro)** - Execute visual scripts directly on your website  
- **[Built for AI Coding Agents](https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/intro)** - The free [Bitbybit CAD MCP](https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/mcp/bitbybit-mcp) gives Claude Code, Cursor, VS Code, claude.ai and ChatGPT the exact API of the version you use; with a key, the [CAD Cloud MCP](https://learn.bitbybit.dev/learn/using-ai-with-bitbybit/mcp/cad-cloud-mcp) runs the geometry too  
- **[Business & Enterprise](https://bitbybit.dev/b2b)** - We help businesses and enterprises develop custom applications and spin up optimized CAD tenant workflows on our managed servers  

## Support the Project

This package is part of the open-source Bitbybit ecosystem. Your subscription helps fund continued development.

⭐ **[Subscribe - Silver or Gold plan](https://bitbybit.dev/auth/pick-plan)** | **[Get API Key for CAD Cloud](https://bitbybit.dev/auth/pick-plan?api-keys=true)**

## Community

- [Discord](https://discord.gg/GSe3VMe)  
- [YouTube](https://www.youtube.com/@bitbybitdev?sub_confirmation=1)  
- [LinkedIn](https://www.linkedin.com/company/bitbybit-dev)  
- [X (Twitter)](https://x.com/bitbybit_dev)  
- [Blog](https://learn.bitbybit.dev/blog)  

## Major Dependencies

Three.js, OpenCascade, JSCAD, Manifold, Verbnurbs

## License

MIT © [Bit By Bit Developers](https://bitbybit.dev)