# CAD-003 — Geometry Forge: bounded industrial mesh authoring

**Status:** experimental implementation candidate, not a production release. Builds on [CAD-002](CAD_002.md) and the [Apache-2.0 DabbleCAD attribution](DABBLECAD_NOTICE.md). Reviewed baseline: `QSOLKCB/VANILLAJS@9ad2e559b8b6964162235ed63dc459046ee13b73` (merged PR #142).

## Delivered source and scope

**Pure geometry** is implemented in [modules/cad-geometry/index.js](../modules/cad-geometry/index.js), as opt-in additions to the existing CAD-001/002 module. All original lathe, profile, OBJ, native RGB, editor scene and replay APIs retain their signatures. No physics, projectile, line-of-sight, graphics renderer, world-collision or history source has been replaced.

- `createForgeExtrusion({footprint,height,bevel})` validates an owned, strictly **counterclockwise convex X/Z polygon** of 3–12 points and extrudes it vertically along **+Y**. The points must be metres in ±5 m, ≥0.01 m edge lengths and no near-collinear corners; geometry is bounded by the existing 1,536-vertex and 64 KiB OBJ limits. Heights are 0.2–10 m.
- `createForgePreset({kind,width,depth,height,bevel})` supplies four original structural footprints: `wall`, `platform`, `tower` (hexagonal), and `wedge`. `forgePresetFootprint` exposes their inert validated X/Z data for editor preview. Dimensions/parameters remain bounded.
- **Real chamfers:** `bevel=0` yields straight walls; a positive bevel offsets each polygon's supporting edge inward by its actual metric distance. It constructs planar bottom/top inset caps, lower and upper diagonal bands and a vertical middle band. Too-small, collapsed or overlarge bevels fail closed; bevels are capped at 1 m and require vertical clearance. This is a **flat geometric chamfer**, not a smooth subdivision fillet or CSG operation.
- `inspectForgeTriangles(meshOrXYZUV)` reports triangle count, welded vertex/edge count at **six-decimal OBJ precision**, degenerate faces, open/overfull edges, directed-edge inconsistencies, signed tetrahedral volume, absolute volume, surface area, Euler characteristic and conservative `closed` status. It **does not repair imported geometry** or certify arbitrary solids with holes, self-intersections or multiple disconnected shells.
- `forgeVolumeReference({footprint,height,bevel})` integrates polygon cross-sectional areas independently of triangulation, using exact-for-quadratic Simpson integration over each linearly interpolated bevel/straight band. Any generated solid whose signed tetrahedral volume disagrees with the independent section-volume reference is rejected by the workshop before being admitted as an asset.
- `cadMeshOBJ` and `cadColorStream` are **unchanged CAD-001 output paths**. They emit source-attributed, deterministic OBJ and packed native Float32 XYZ/RGB respectively. Geometry is original and shipped with no new packages, fonts, shaders, WASM or imported graphics.

**Visual Editor:** The existing [Visual Editor](../demos/editor/index.html) contains a **CAD-003 Geometry Forge** section in Asset Foundry. Select one of four presets or enter a custom convex outline as a bounded semicolon-separated list of `x,z` numeric pairs. The Canvas2D workplane previews geometry separately from the native WebGL editor. Choose height and chamfer, then press **Generate & Place Forge Solid**. It creates a *new*, ordinary static entity and SHA-256-provenanced Apache-2.0 mesh asset through the existing strict `addMeshAsset` and `setPlacement` validators. Project save/reopen, selection, scene hierarchy, Undo/Redo and native `createSceneVertices` all remain operative.

**Build Demonstration Compound (6 solids)** creates an original industrial construction scene from two towers, a front barricade, two deflectors and a loading platform. Each solid is independently validated and SHA-256 hashed; the editor stages the entire six-mesh asset library plus six new static entities before committing once. One scene Undo removes all six placements. The resulting project remains an ordinary owner-exported offline JSON file with all six source records and can be reopened without DabbleCAD or an additional runtime.

**Inspect selected mesh topology** reads an attached or selected mesh asset's existing XYZ/UV triangle data and displays actual boundary, degeneracy, winding and volume diagnostics; malformed imports are not transformed or silently healed. The CAD editor shape remains a visual mesh and its entity retains the existing AABB **collision proxy**, which is deliberately not replaced by a triangle physics solver.

### Independent reference and tests

~~~sh
node --test tests/cad-forge.test.js tests/cad-geometry.test.js tests/cad-profile.test.js
node --test tests/*.test.js
node scripts/check.js
node scripts/build.js
node scripts/verify-offline.js
~~~

The validator requires **global supporting-half-plane convexity** (every non-endpoint vertex must lie strictly inside every directed edge), in addition to positive signed area and local turns. This rejects self-intersecting pentagrams, which can otherwise pass local-winding and even triangle-topology checks despite not defining a valid solid. A pinned 5/2 star reproduction is tested in both Node and the real Visual Editor browser workflow.

The test suite compares signed tetrahedral face volume against an independent **analytic rectangular chamfer formula** and cross-sectional Simpson volume, with point winding/UV parity, positive closed Euler=2, exact OBJ/parser roundtrip and 144 seeded convex footprints. Negative fixtures cover concave and clockwise outlines, collinear/tiny edges, invalid bevels, nonfinite/accessor/sparse arrays, open and reversed triangles, degenerate faces, duplicate/non-manifold faces, scripts in polygon fields, and existing Asset Foundry save/load and Undo/Redo.

The independent [CAD-003 packaged Chromium workflow](../.github/workflows/cad-forge.yml) checks actual on-screen preview, native WebGL generated tower, custom polygon, selected mesh topology, SHA-256 source ownership and complete project download/reopen. Negative concavity checks and zero external network/errors are mandatory. Screenshot, exact package hash and acceptance JSON are retained.

**Performance:** hosted Chromium/SwiftShader success proves only that hosted packaged browser execution worked. It does not establish 60 FPS on a native RTX 5060 Ti or any other physical GPU. Changes to draw call counts, occlusion/LOD and GPU benchmarks belong to independent **WORLD-VIS-001**.

## Provenance and original work

DabbleCAD was reviewed at `DJMcNewgent/DabbleCAD@9cfd20b0a973275c7f7411afb6e7c355f8a863cc`, Apache-2.0, Copyright 2026 DJMcNewgent. CAD-001's adapted surface-of-revolution method retains its exact donor file notice in [DABBLECAD_NOTICE.md](DABBLECAD_NOTICE.md). **CAD-003's polygon extrusion, chamfer offset, topology/volume references, industrial presets and UI are independently authored QSOL-IMC work.** No third-party CAD, Three.js, Manifold, CSG, Electron, source assets, user datasets, or soundtrack are imported.

The root `NOTICE`, existing source-bound Game Maker/HORIZON/Demoscene archives, published releases and historical evidence are unchanged.

## Explicit non-goals

- Non-convex polygons, holes, boolean subtraction, arbitrary triangulation, manifold proof for arbitrary imported meshes, disconnected shells or certified physical fabrication.
- Bézier curves, bevel edge-segment subdivisions and per-vertex materials.
- Triangle-precise game collisions, automatic physics bodies, in-game destruction, navmesh pathing or any change to SENSE-001 tactical decisions.
- Any source import requiring new runtime dependencies or network access.

**Next separate phase:** WORLD-VIS-001 retained scene visibility and LOD with source-bound draw parity and physical GPU baselines.
