Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/flo-bit/shapecraft. flo-bit.dev/shapecraft
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253import QuickstartDemo from './components/QuickstartDemo.astro'
# Quickstart
## Install
```bashnpm install shapecraft three```
Three.js is a peer dependency — you provide it.
## Basic usage
```tsimport { box, sphere, merge } from 'shapecraft'import { toThreeMesh } from 'shapecraft/three'
const b = box({ size: 1 })const s = sphere({ radius: 0.5 }).translate(2, 0, 0)const combined = merge(b, s)
const threeMesh = toThreeMesh(combined)scene.add(threeMesh)```
<QuickstartDemo />
## Core idea
Everything is a `Mesh`. Primitives return meshes. Transforms and modifiers return **new** meshes (immutable). You compose by chaining method calls and merging results.
```tsconst leg = cylinder({ radius: 0.05, height: 1 }) .translate(0, 0.5, 0) .vertexColor('#8B4513')
const seat = box({ width: 1, height: 0.1, depth: 1 }) .translate(0, 1, 0) .vertexColor('#A0522D')
const chair = merge(seat, leg.translate(-0.4, 0, -0.4), leg.translate(0.4, 0, -0.4), leg.translate(-0.4, 0, 0.4), leg.translate(0.4, 0, 0.4))```
## Running the demo
```bashnpm run dev```
Opens a Vite dev server with a demo scene at `http://localhost:5173`.