Skip to content

About

No description, website, or topics provided.

Resources

Contributing

Stars

9 stars

Watchers

0 watching

Forks

Repository files navigation

ClothCraft

An open-source garment editor and cloth simulation prototype, written in Rust.

Draw patterns, sew them together, place them around an avatar and simulate the result. Most work so far has gone into building a physics foundation that can handle difficult contact. The editor, interchange formats and material calibration need substantial work.

This is a research prototype, not a production garment tool. Expect unfinished interactions, residual oscillation, slow simulation on dense meshes and cases that still fail. Help is welcome with the interface, physics, testing, documentation and file formats. You do not need to be a programmer to contribute a useful reproduction, workflow sketch or testable hypothesis.

Measuring a pattern piece

With Measure, click two locations on the same editable polygon panel. The ruler shows their straight-line distance in flat garment material, in millimetres. Moving or rotating the piece on the board preserves the measurement. Scaling or reshaping the piece updates the distance.

Straight boundary picks store the named edge and an integer station. Settings cycles the precision for new picks through 8 (default), 10 and 16 bits. The garment JSON saves this preference and each station's precision. Codes from zero to 255, 1023 or 65535 include both ends exactly. On a straight edge of length L, rounding moves a pick by at most L / (2 × maximum code). Splitting an edge remaps its station to the correct child and can incur another rounding step. Older fractional stations and curved-edge arclength stations retain their original representation.

Interior picks store three authored contour corners and dimensionless barycentric weights. When a corner moves or disappears, the ruler looks for three surviving corners enclosing the mark that kept their relative positions. When available, they carry the mark through the edit, including any shift of the panel's local origin. Otherwise the mark follows its existing material triangle or a triangle of surviving corners. The ruler can then select a new local triangle and compute fresh weights at the resulting position. Scaling or shearing the entire piece carries the mark with it. An edit that removes the material beneath a mark or leaves no usable reference frame can require redefining the measurement.

ClothCraft workspace

In either native window, click the solver badge in the top bar to choose the active solver. Switching pauses at the displayed cloth state; press Play or Step to continue. Fitting offers WGSL AVBD/IPC and CPU VBD/OGC; the Project demo offers WGSL AVBD/IPC and CPU reference Newton. These use different contact laws. The dropdown also offers the experimental AVBD + barrier AL backend, implemented after saving its design and scalar study. Its fixed budget does not certify convergence.

The two WGSL options now use a coupled GPU correction for the reported default T-shirt protrusion. Matched 200-step runs and an opt-in garment quality regression compare against the unchanged CPU solver. Start from a fresh garment when checking this update; an already distorted cached state can retain its earlier assembly history.

Try it

Install Rust stable and run from the repository root:

cargo run --release --locked -j 2 --bin cloth-fit -- --steps 0 --view

The editor opens a T-shirt and the bundled MakeHuman mannequin. Windows is the main development platform; macOS and Linux need equivalent acceptance testing. The desktop requires a graphics adapter supported by wgpu. CPU command-line tools build without graphics dependencies.

Plain cargo run --locked -j 2 opens the cloth-over-sphere demo with the same WGSL default; --cpu selects historical Newton. Headless execution uses --headless, independently of solver selection. In that window, open Properties → REST PATTERN → Physics-inspired mesh preparation (also available in Simulation) and click Remesh and reset before simulating. Use uniform grid and reset restores the original grid. See mesh preparation inputs and limits.

To reopen a saved garment:

cargo run --release --locked -j 2 --bin cloth-fit -- --project path/to/garment.json --steps 0 --view

Use Space to start or pause, Grab to pull the cloth and Ctrl+S to save. Grab exposes radius and strength above the 3D view; 3D gear → Clean view hides editing annotations. Right-click a canvas for the radial tool menu. Q opens nearby shape, mirror and boolean actions. The 2D board and 3D viewport share panel and boundary selections.

What works today

  • Patterns: rectangles, ellipses, arc sectors, Bézier contours, point editing, holes and internal sewing paths; independent and paired linked mirrors; two-piece booleans.
  • Sewing: whole boundaries, partial ranges and ordered multi-edge chains, with direction, explicit easing and editable relationships.
  • Arrangement: translation and rotation in 3D; a separate 2D board layout; undo/redo and semantic copy/paste.
  • Simulation: resident WGSL finite AVBD with IPC-style contact by default on this branch; explicit CPU and hybrid VBD/OGC controls remain available. The floor is currently a visual reference, not a physical collider.
  • Documents: Open, Save, Save As, portable avatar assets and local recovery. Keep a saved JSON and its adjacent .assets folder together.
  • Starting assets: six bundled pattern templates, native template JSON import, and static OBJ/glTF/GLB/FBX/USD avatars through the fitting editor's Assets & Pieces → Import → Avatar action. Avatar replacement preserves authored patterns but resets the drape and undo history; supported geometry and limits.
  • Avatar inspection: Properties → Simulation reports the actual collision mesh and can check the current arrangement through the CPU solver's initialization gate. Coverage and limits: topology warnings are not an intersection or global containment certificate.
  • DXF outlines: The fitting editor's Assets & Pieces → Import → DXF action previews units, layers and excluded data before adding selected closed outlines as editable pieces. Existing unchanged panels retain their drape. This is a generic planar subset, not industrial DXF-AAMA/ASTM.
  • SVG outlines: The fitting editor's Assets & Pieces → Import → SVG action adds selected closed outlines from a physically scaled SVG subset. Curves are sampled into polygon edges; unsupported artwork and nested or overlapping selected outlines are rejected rather than interpreted as sewing or holes.
  • Net material report: the CPU cloth-template metrics command reports rest-mesh area and cloth mass per panel and fabric. It is not cutting or purchasing consumption; see units and limits.

Select two boundaries in Sew, then confirm the nearby proposal; unequal lengths offer an explicit easing action. In Edit, box/lasso can select contour points across patterns for one group move; Delete removes selected pieces when no point, seam or text field owns the action. See editing and inspection controls.

These are implemented foundations, not completed production workflows. See the workspace guide, document and sewing guide and authoring reference for controls and limitations.

Physics: strengths and open problems

The default in desktop-enabled builds is an independent WGSL finite AVBD / Jacobi pipeline with a squared-distance IPC-style barrier. Contact search, geometry, forces, path bounds and iteration decisions remain on the GPU; one snapshot returns per step for UI/export. This implements a proposal in the earlier repository, with explicit scope, numerical limits and commands. It is not the complete published AVBD or IPC solver, and no dense-garment speedup is claimed. CPU VBD/OGC (cloth-fit --cpu), historical hybrid VBD/OGC (--hybrid-vbd) and double-precision Newton (--reference) remain available.

Contact protections are designed to preserve separation from an initially separated arrangement, within the documented geometric assumptions and local seam exclusions. They do not repair arbitrary initial intersections or guarantee every possible garment. See the contact contract.

The main open problems are residual motion under tension, convergence, cost at fine mesh resolutions, friction, seam treatment and measured material calibration. Some test scenes run in real time; that does not establish a universal performance guarantee. Rendering FPS and simulation speed are different: a smooth viewport can show cloth progressing slower than wall time. Comparisons must report simulated seconds per wall second and full-step timings, alongside collision and deformation checks.

The headless solver lab contains experimental XPBD/OGC, finite-stiffness AVBD adaptations and a separate native Box3D particle lattice. Their failures are recorded; they are not alternative editor modes. Small contact research kernels are also not garment-ready solvers. The GPU default on this branch is separate from those CPU lab adapters.

The long-term goal is interchangeable physics behind a stable document and authoring model. There is no public solver plugin ABI yet. A useful solver contribution must preserve collision coverage and fluid pull/release behavior, not just reduce a jitter number.

Files

Data Input Output
Editable garment ClothCraft project / template JSON Project / template JSON
Static avatar OBJ, static glTF / GLB, FBX 7.x ASCII/binary, USD (USDA/USDC/USDZ) geometry; multi-mesh sources can exclude helper meshes from the collider —
Simulated garment mesh — OBJ geometry and material-space UVs
2D patterns Selected closed outlines from generic planar ASCII DXF and physically scaled SVG subsets Annotated SVG preview and millimetre-scale sewing outlines with stored seam allowances and sewing-line notches when present, and a 100 mm ruler; notches are not duplicated onto cutting lines; no tiling or cutting certification
Research data — Metrics, fiber frames and geometric grain guides

DXF-AAMA/ASTM, MTL round trips, glTF/GLB mesh export, animated avatars, Alembic, USD/FBX mesh export and skinning/material interchange, PDF printing and grading rules remain planned. FBX and USD currently cover static avatar mesh import only; editable USDA template and project documents are a separate capability. Native project files from other draping software are not supported. Save preserves the editable document; Export writes separate interchange artifacts. See the input/output contracts.

Help build it

This fork uses a software factory: a weighted implementation queue, local agent communications in gitignored comms/, and feature PRs reviewed and merged through gh. Codex reviews and sensible fixes are welcome throughout implementation. See CONTRIBUTING.md for development guidance, and the EXO feature audit and optional backlog for planning context.

Choose a track from the roadmap:

  • Make editing understandable: sewing feedback, selection, arrangement, measurement and accessibility. An unfamiliar person should be able to make a simple garment without reading implementation details.
  • Improve the solver: profile full steps, investigate contact continuity and convergence, or build an alternative behind the same benchmark contract. Retain failed experiments and disclose tradeoffs.
  • Connect other tools: implement a small, tested import or export slice with explicit units and supported entities.
  • Test real workflows: share an original garment you may redistribute, exact steps, settings and expected behavior. A small failing example is valuable.

Start with CONTRIBUTING.md. The contributor kit includes task briefs, an issue checklist and prompts you can give a coding assistant. Agents should read AI_START_HERE.md and AGENTS.md before editing. Validate changes whether written by a person, an AI assistant or both.

Development

cargo test --locked --no-default-features -j 2 -- --test-threads=2
cargo clippy --locked --no-default-features --all-targets -j 2 -- -D warnings
cargo build --locked -j 2

On Windows, scripts/check-cpu.ps1 runs the CPU checks. GPU tests and native window checks are opt-in; coordinate GPU use with the machine's owner. The headless physics lab and settling zoo provide reproducible fixtures without opening the editor.

Area Start here
Documents and editing src/document.rs, src/fitting.rs, src/authoring.rs
Patterns, meshing and seams src/garment/
Desktop workspace src/atelier/
Material energy and reference solver src/energy.rs, src/solver.rs
Interactive physics and contact src/vbd.rs, src/ogc/, src/gpu_vbd.rs
Research adapters src/solver_lab/, examples/solver_compare.rs

The architecture, handoff and solver challenge explain the contracts and evidence.

License and credits

Original source and documentation are MIT-licensed. The bundled MakeHuman assets retain their CC0 notice and provenance; dependencies retain their own licenses. The project icon is documented in the artwork record.

This repository began as a snapshot, so its Git history does not show the original contributors. See contributor credits for the people and author identities recorded in the earlier history, and links to the source history.

Some authoring and camera tools were adapted from FireflyTheReal / julienfoss's fork; the integration notes record provenance and fixes.

ClothCraft is independent of other draping software vendors and ArtCraft. Public manuals inform workflow research; proprietary code, icons and garment examples are not included. The manual study records the references consulted.

The resident WGSL performance follow-up records GPU-only caching/filtering changes, the unchanged CPU control, passing default-garment quality gates, and 2.1–3.3x complete-step gains. The hybrid control remains faster on the measured M1 Pro.

The garment window also exposes Mesh preparation with a Coarse–Fine slider, smooth transitions and named-path fold, gathering and down-fill sizing controls. See usage and limits. Applying prepares a static rest mesh and resets the drape.

About

No description, website, or topics provided.

Resources

Contributing

Stars

9 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages