chore(gamut): replace inlined QuickHull with Three.ConvexGeometry #117

Closed
opened 2026-08-26 15:17:01 +01:00 by gronod · 1 comment
Owner
Field Value
Labels Kind/Enhancement, Priority/Low
Priority Low
Milestone v0.3.3 hotfix (optional) or v0.4.0
Related #89
Branch chore/gamut-convex-geometry (from development)
Pair with

Description

#89 inlined a 3D QuickHull in src/js/gamut_viewer.js (~270 lines) instead of MIT quickhull3d or Three.js ConvexGeometry (already a port of quickhull3d). Touch / OrbitControls work and should be left alone.

This is optional. Do not start it until issues 01–04 have merged.

Current behaviour

Risks in compute3DConvexHull:

  • Horizon edges stored as min_u_max_v; winding recovered via the initial tetrahedron centroid, not the growing hull.
  • Duplicate filtering is O(n²).
  • No tests. A missing face on a re-entrant .gam is hard to spot visually.

three.min.js is r128. Delaunator is unused (delaunator.min.js is deleted in issue 07).

Proposed solution

Vendor examples/jsm/geometries/ConvexGeometry.js and examples/jsm/math/ConvexHull.js from the same Three r128 line as three.min.js (MIT), or add quickhull3d as a single ESM file under src/js/vendor/.

renderGamutFromText:

  1. parseCGATSTHREE.Vector3(a, L, b)
  2. new ConvexGeometry(points)
  3. Same Lambert material as today (wireframe / solid, double-sided, existing opacities)

Keep compute3DConvexHull only if a golden-file test against src/assets/sRGB.gam is added (vertex count + watertight index buffer). Otherwise delete it.

Do not change OrbitControls touch mapping (ONE: ROTATE, TWO: DOLLY_PAN).

Files

  • src/js/gamut_viewer.js
  • src/js/vendor/ConvexGeometry.js (new) and src/js/vendor/ConvexHull.js (new), or equivalent
  • src/index.html — script tags if not ESM-imported

Acceptance criteria

  • sRGB wireframe and a printer .gam both render, rotate, and pinch-zoom as in v0.3.2.
  • No Delaunator 2D path remains.
  • Hull of a regular tetrahedron fixture has 4 faces; hull of a cube fixture has 12 triangles.
  • A 1500-vertex cloud completes without dropping below 30 fps in the existing viewer.
  • OrbitControls one-finger rotate and two-finger pinch/pan are unchanged.

Dependencies

After issues #109 #110 #111 #112 . Optional for v0.3.3; may slip to v0.4.0.

| Field | Value | |---|---| | Labels | `Kind/Enhancement`, `Priority/Low` | | Priority | Low | | Milestone | v0.3.3 hotfix (optional) or v0.4.0 | | Related | #89 | | Branch | `chore/gamut-convex-geometry` (from `development`) | | Pair with | — | ## Description #89 inlined a 3D QuickHull in `src/js/gamut_viewer.js` (~270 lines) instead of MIT `quickhull3d` or Three.js `ConvexGeometry` (already a port of quickhull3d). Touch / OrbitControls work and should be left alone. This is optional. Do not start it until issues 01–04 have merged. ## Current behaviour Risks in `compute3DConvexHull`: - Horizon edges stored as `min_u_max_v`; winding recovered via the **initial tetrahedron centroid**, not the growing hull. - Duplicate filtering is O(n²). - No tests. A missing face on a re-entrant `.gam` is hard to spot visually. `three.min.js` is r128. `Delaunator` is unused (`delaunator.min.js` is deleted in issue 07). ## Proposed solution Vendor `examples/jsm/geometries/ConvexGeometry.js` and `examples/jsm/math/ConvexHull.js` from the same Three r128 line as `three.min.js` (MIT), **or** add `quickhull3d` as a single ESM file under `src/js/vendor/`. `renderGamutFromText`: 1. `parseCGATS` → `THREE.Vector3(a, L, b)` 2. `new ConvexGeometry(points)` 3. Same Lambert material as today (wireframe / solid, double-sided, existing opacities) Keep `compute3DConvexHull` only if a golden-file test against `src/assets/sRGB.gam` is added (vertex count + watertight index buffer). Otherwise delete it. Do not change OrbitControls touch mapping (`ONE: ROTATE`, `TWO: DOLLY_PAN`). ## Files - `src/js/gamut_viewer.js` - `src/js/vendor/ConvexGeometry.js` (new) and `src/js/vendor/ConvexHull.js` (new), or equivalent - `src/index.html` — script tags if not ESM-imported ## Acceptance criteria - [ ] sRGB wireframe and a printer `.gam` both render, rotate, and pinch-zoom as in v0.3.2. - [ ] No `Delaunator` 2D path remains. - [ ] Hull of a regular tetrahedron fixture has 4 faces; hull of a cube fixture has 12 triangles. - [ ] A 1500-vertex cloud completes without dropping below 30 fps in the existing viewer. - [ ] OrbitControls one-finger rotate and two-finger pinch/pan are unchanged. ## Dependencies After issues #109 #110 #111 #112 . Optional for v0.3.3; may slip to v0.4.0.
gronod added this to the v0.3.3 Hot fixes milestone 2026-08-26 15:17:01 +01:00
gronod added the Kind/Enhancement
Reviewed
Confirmed
1
Priority
Low
4
labels 2026-08-26 15:17:01 +01:00
gronod changed title from # chore(gamut): replace inlined QuickHull with Three.ConvexGeometry to chore(gamut): replace inlined QuickHull with Three.ConvexGeometry 2026-08-27 15:31:46 +01:00
Author
Owner

Resolved via PR #125. Modularized QuickHull 3D into src/js/vendor/quickhull.js and verified with tetrahedron (4 faces) and cube (12 triangles) fixtures.

Resolved via PR #125. Modularized QuickHull 3D into `src/js/vendor/quickhull.js` and verified with tetrahedron (4 faces) and cube (12 triangles) fixtures.
Sign in to join this conversation.