polyform

EliCDavisMIT活跃维护

用 Go 写的不可变网格处理库,支持 glTF、OBJ、PLY 等格式,适合做程序化几何生成和 3D 网格编辑。

Immutable mesh processing library

v0.44.0发布于 2026-11-06 04:16 UTC232star24fork同步于 2026-11-10 12:04 UTC

怎么上手

由 README 提炼,执行前请确认
npm install && npm run build-dev
go run ./cmd/polyform edit
硬件要求按 README 说明

README 未说明显存或 GPU 要求;编辑器为浏览器端 React 应用,可本地运行,也提供 WASM 版本在浏览器中使用

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

Go 编写的不可变网格处理库,带节点式可视化编辑器,用于程序化生成和编辑 3D 几何

用 Go 写的不可变网格处理库,支持 glTF、OBJ、PLY 等格式,适合做程序化几何生成和 3D 网格编辑。

核心能力

  • 以不可变数据结构组织网格,便于组合与复用
  • 提供节点式可视化编辑器,可拖拽搭建程序化流程
  • 内置 marching cubes、挤出、三角化等建模算法
  • 支持 gltf、obj、ply、stl 等格式的读写
  • 附带 SDF、噪声、四元数、空间划分树等数学工具

容易踩的坑

前端产物 generator/edit/html/js/ 被 gitignore,新克隆仓库必须先跑 npm run build-dev 才能启动编辑器;需要 Go 1.21+ 与 Node.js 20.19+ 或 22.12+;默认服务端口为 8080,WebXR 等特性需自行用 mkcert 配置 HTTPS

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v0.44.0
  1. v0.44.0v0.44.0 - Enums, Port Literals + Casting, Subgraph For Each最新正式版2026-11-06 · 2026-11-06 04:16 UTC

    What's Changed

    Massive Breaking Changes

    Full Changelog: https://github.com/EliCDavis/polyform/compare/v0.43.1...v0.44.0

  2. v0.43.12026-10-21 · 2026-10-21 03:39 UTC
    查看更新说明
  3. v0.43.0Sketching + Spreading Nodes2026-10-19 · 2026-10-19 03:37 UTC
    查看更新说明

    What's Changed

    Full Changelog: https://github.com/EliCDavis/polyform/compare/v0.42.1...v0.43.0

  4. v0.42.12026-10-13 · 2026-10-13 03:34 UTC
    查看更新说明
  5. v0.42.0Dynamic Ports2026-10-12 · 2026-10-12 01:58 UTC
    查看更新说明

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    Polyform Banner Coverage Go Report Card Go Reference CITATION.cff

    Polyform is a toolkit for developers and artists to load, generate, edit, and export 3D geometry with a focus on immutability, modularity, and procedural workflows.

    Developers and artists are welcome to join the Discord to share feedback, get help, or discuss feature requests.

    Try in 30 Seconds

    Try it now in your browser → Live Demo

    To run it locally, you can download the latest release and run:

    # Launches the node based editor
    polyform edit
    
    # If Golang is installed, clone and run:
    npm install && npm run build-dev
    go run ./cmd/polyform edit
    
    # If Nix is installed, run:
    nix run .#polyform edit
    

    Package Overview

    • Formats
      • gltf - GLTF file format
      • obj - OBJ file format
      • ply - PLY file format
      • stl - STL file format
      • colmap - Utilities for loading COLMAP reconstruction data
      • opensfm - Utilities for loading OpenSFM reconstruction data
      • splat - Mkkellogg's SPLAT format
      • spz - Niantic Scaniverse's SPZ format
      • potree - Potree V2 file format
    • Modeling
      • extrude - Functionality for generating geometry from 2D shapes.
      • marching - Multi-threaded Cube Marching algorithm and utilities.
      • meshops - All currently implemented algorithms for transforming meshes.
      • primitives - Functionality pertaining to generating common geometry.
      • repeat - Functionality for copying geometry in common patterns.
      • triangulation - Generating meshes from a set of 2D points.
    • Drawing
      • coloring - Color utilities for blending multiple colors together using weights.
      • texturing - Traditional image processing utilities (common convolution kernels).
        • normals - Utilities for generating and editing normal maps.
    • Math
      • bias - Generic, temperature-scaled, biased random sampler for weighted selection of items
      • colors - Making working with golang colors not suck as much.
      • curves - Common curves used in animation like cubic bezier curves.
      • geometry - AABB, Line2D, Line3D, Plane, and Rays.
      • kmeans - Generic k-means clustering algorithm across 1D to 4D vector spaces.
      • mat - 4x4 Matrix implementation
      • noise - Utilities around noise functions for common usecases like stacking multiple samples of perlin noise from different frequencies.
      • quaternion - Quaternion math and helper functions.
      • sdf - SDF implementations of different geometry primitives, along with common math functions. Basically slowly picking through Inigo Quilez's Distfunction article as I need them in my different projects.
      • predicate - Shewchuk's adaptive precision predicates: which side of a line or plane a point is on, and whether it lies in a circle, with a sign that is exact.
      • sample - Serves as a group of definitions for defining a mapping from one numeric value to another.
      • sfc - Space-filling curves. Hilbert (2D) and Morton / Z-order (3D) encoders that map points to and from 64-bit keys that keep spatial neighbours close together.
      • trs - Math and utilities around TRS transformations.
    • Generator - Application scaffolding for editing and creating meshes.
    • Trees - Implementation of common spatial partitioning trees.

    Packages that have spawned from polyform's undertaking and have since been refactored into their own repositories:

    • Node Flow - Another Flow-based Node Graph Library
    • vector - Immutable vector math library
    • jbtf - GLTF-inspired JSON schema for embedding arbitrary binaries
    • iter - Iterator and utilities. Some inspiration from ReactiveX
    • quill - Scheduler of operations on in-memory data
    • sfm - Utilities for interacting with reconstruction data from different SFM programs
    • bitlib - Utilities for reading and writing binary data

    Contributing

    Learn how to create your own nodes for others to use.

    Procedural Generation Examples

    You can at the different projects under the examples folder for different examples on how to procedurally generate meshes.

    Evergreen Trees

    This was my submission for ProcJam 2022.

    [Source Here]

    Evergreen Tree Demo

    Other Examples

    [Source Here] ufo[Source Here] candle
    [Source Here] terrain[Source Here] terrain
    [Source Here] plumbob[Source Here] oreo

    Processing Example

    Reads in a obj and applies the cube marching algorithm over the meshes 3D SDF.

    package main
    
    import (
      "github.com/EliCDavis/polyform/formats/obj"
      "github.com/EliCDavis/polyform/modeling"
      "github.com/EliCDavis/polyform/modeling/marching"
      "github.com/EliCDavis/polyform/modeling/meshops"
      "github.com/EliCDavis/vector"
    )
    
    func main() {
      objScene := obj.Load("test-models/stanford-bunny.obj")
    
      resolution := 10.
      scale := 12.
    
      transformedMesh := objScene.ToMesh().Transform(
        meshops.CenterAttribute3DTransformer{},
        meshops.ScaleAttribute3DTransformer{Amount: vector3.Fill(scale)},
      )
    
      canvas := marching.NewMarchingCanvas(resolution)
      meshSDF := marching.Mesh(transformedMesh, .1, 10)
      canvas.AddFieldParallel(meshSDF)
    
      obj.SaveMesh("chunky-bunny.obj", canvas.MarchParallel(.3))
    }
    

    Results in:

    Chunky Bunny

    Local Development

    Polyform's visual editor is a React + TypeScript app in web/, built with Vite and served by the Go edit command. The Go binary embeds the built JS at compile time, so frontend changes require an npm build before go build picks them up.

    Prerequisites

    • Go 1.21+ (to run the edit server and build the CLI)
    • Node.js 20.19+ or 22.12+ and npm (to build the web UI)

    First-time setup

    git clone https://github.com/EliCDavis/polyform.git
    cd polyform
    npm install
    npm run build-dev   # writes generator/edit/html/js/index.js
    go run ./cmd/polyform edit
    

    Open http://localhost:8080 (or whatever port the server prints).

    generator/edit/html/js/ is gitignored. A fresh clone has no bundled JS until you run npm run build-dev.

    Web UI development

    For UI work, run the Go API server and the Vite dev server together. Vite gives you hot module replacement (HMR); API calls are proxied to Go.

    Terminal 1 — Go backend:

    go run ./cmd/polyform edit
    # or, with live reload for Go changes:
    air edit
    

    Terminal 2 — React frontend:

    npm run watch-dev
    

    The Vite dev server proxies REST and WebSocket traffic to localhost:8080. If your Go server uses a different port, update the proxy targets in web/vite.config.mts.

    Go-only development

    If you are only changing Go code and not the web UI, you can skip Vite and use the last built bundle:

    npm run build-dev   # only when web/ changed
    go run ./cmd/polyform edit
    

    npm scripts

    ScriptPurpose
    npm run watch-devVite dev server with HMR (local UI development)
    npm run build-devProduction bundle → generator/edit/html/js/index.js
    npm run build-prodSame as build-dev with production mode

    Live reload with Air

    Air reloads the Go server when backend files change. Include frontend source extensions if you want Air to restart when you touch the web tree (you still need Vite for HMR):

    # .air.toml
    [build]
      cmd = "npm run build-dev && go build -o ./tmp/main.exe ./cmd/polyform"
      include_ext = ["go", "tpl", "tmpl", "html", "ts", "tsx"]
    

    Then:

    air edit
    

    For active UI work, prefer npm run watch-dev + go run ./cmd/polyform edit instead of rebuilding the bundle on every save.

    HTTPS / WebXR

    Some browser features (WebXR, shared memory) need HTTPS. mkcert is a simple way to get local TLS certs:

    mkcert -install
    mkcert -key-file key.pem -cert-file cert.pem localhost
    air edit --port 8080 --ssl
    
    # To reach a VR headset on your LAN:
    air edit --port 8080 --ssl --host 0.0.0.0
    

    When using Vite alongside TLS Go, point the Vite proxy at your HTTPS origin or run without Vite and use the embedded bundle from polyform edit --ssl.

    WASM deployment

    The same web bundle is embedded into a WASM build of the CLI. Build the JS first, then compile WASM:

    npm run build-dev
    go install ./cmd/polywasm
    GOOS=js GOARCH=wasm go build -ldflags="-w -s" -o main.wasm ./cmd/polyform
    polywasm build --wasm main.wasm
    polywasm serve   # serves the static wrapper (splash + service worker + main.wasm)
    

    Nix release builds run npm run build-dev automatically before go build (see flake.nix).

    Nix

    nix run .#polyform edit
    

    The Nix derivation builds the website npm package and copies generator/edit/html/* into the Go build before compiling.

    Citation

    If Polyform contributes to an academic publication, cite it as:

    @misc{polyform,
      title = {Polyform},
      author = {Eli Davis},
      note = {https://www.github.com/EliCDavis/polyform},
      year = {2025}
    }