MCPcopy Index your code
hub / github.com/ModelRift/terrain-to-3d

github.com/ModelRift/terrain-to-3d @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
154 symbols 342 edges 37 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Terrain To STL

This is a simple browser-based editor which creates printable 3D terrain models (.stl) from just latitude and longitude input.

Demo: https://terrain.modelrift.com

Built by ModelRift team. ModelRift is an AI-enhanced browser-based IDE for OpenSCAD.

Uses awesome OpenSCAD WASM build by @DSchroer so all the magic happens right in your browser.

UI is built using React and Shadcn. Three.js is used as a model viewer.

How it works

  • Step 1 downloads elevation tiles and builds a grayscale heightmap of the chosen lat/long. Terrain data is downloaded from this public dataset. Interesting read on how the terrain tiles are encoded

  • Step 2 generates OpenSCAD code and compiles an STL in the browser (WASM worker).

  • Three.js renders the produced .stl model in a browser, with a beautiful lightning applied.

What you can control

  • Center point: latitude and longitude
  • Area size in km
  • Heightmap resolution
  • Tile zoom level
  • Model size in mm
  • Z exaggeration
  • Base thickness

How To Run

Docker Compose

docker compose up --build -d

Open http://localhost:8083.

Development (Docker Compose)

Big map rendering is slow in dev mode!

docker compose -f docker-compose.dev.yml up --build

Open http://localhost:5176.

Development (Local pnpm)

pnpm install
pnpm dev

Then open the Vite URL from terminal output and: 1. Click Download Terrain 2. Click Generate STL 3. Download terrain.stl (or terrain.scad)

Notes

  • Terrain data is fetched from Terrarium elevation tiles.
  • Internet access is required while fetching terrain data.

Extension points exported contracts — how you extend this code

ImportMetaEnv (Interface)
(no doc)
src/env.d.ts
Props (Interface)
(no doc)
src/components/status-bar.tsx
TerrainParams (Interface)
(no doc)
src/lib/terrain.ts
WorkerRequest (Interface)
(no doc)
src/workers/openscad.worker.ts
ImportMeta (Interface)
(no doc)
src/env.d.ts
Props (Interface)
(no doc)
src/components/scad-viewer.tsx
HeightmapResult (Interface)
(no doc)
src/lib/terrain.ts
Props (Interface)
(no doc)
src/components/log-pane.tsx

Core symbols most depended-on inside this repo

cn
called by 70
src/lib/utils.ts
set
called by 10
src/components/terrain-controls.tsx
post
called by 10
src/workers/openscad.worker.ts
parseNumber
called by 8
src/lib/url-state.ts
clamp
called by 7
src/lib/url-state.ts
formatSize
called by 3
src/lib/openscad.ts
downloadBlob
called by 3
src/lib/download.ts
readGitValue
called by 2
vite.config.ts

Shape

Function 136
Interface 18

Languages

TypeScript100%

Modules by API surface

src/components/ui/combobox.tsx16 symbols
src/components/ui/dropdown-menu.tsx15 symbols
src/components/ui/alert-dialog.tsx12 symbols
src/components/ui/select.tsx10 symbols
src/components/ui/field.tsx10 symbols
src/components/terrain-viewer.tsx9 symbols
src/lib/terrain.ts8 symbols
src/lib/geotiff-heightmap.ts7 symbols
src/components/ui/card.tsx7 symbols
src/lib/url-state.ts6 symbols
src/components/ui/input-group.tsx6 symbols
src/components/terrain-controls.tsx6 symbols

For agents

$ claude mcp add terrain-to-3d \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact