Skip to content

feat(ai): GLB pipeline v2 — semantic scene graph architecture#10

Merged
ofcskn merged 2 commits into
developmentfrom
feature/glb-pipeline-v2-scene-graph
May 18, 2026
Merged

feat(ai): GLB pipeline v2 — semantic scene graph architecture#10
ofcskn merged 2 commits into
developmentfrom
feature/glb-pipeline-v2-scene-graph

Conversation

@ofcskn

@ofcskn ofcskn commented May 18, 2026

Copy link
Copy Markdown
Owner

Summary

  • Replaces flat Gemini output (detectedType + 8 scalar fields) with a rich SceneGraph — a part-by-part descriptor with individual geometry, position, rotation, and PBR material per structural component
  • 4 new geometry primitives in glb-builder.ts: torus (wheels), frustum (car hoods/roofs), tapered-cylinder (bottle necks), extruded-ellipse (car body cross-sections)
  • 9-phase orchestrator in gemini-3d-generator.ts: product understanding → geometry classification → multi-view scene graph reconstruction → category enforcement → per-part PBR materials → scale estimation → validation + auto-repair → GLB encoding → post-encode validation
  • 6 category generators via CategoryGeneratorFactory: vehicle, electronics, furniture, packaging, clothing, jewelry — each enforces domain-specific constraints (e.g., car wheels are always torii, fabric parts always have roughness > 0.7)
  • Phase H validation: SceneGraphValidator catches box wheels, missing vehicle wheels, zero dimensions, implausible scales; autoRepairSceneGraph fixes common errors before encoding
  • Phase I feedback loop: GenerationFeedbackService + migration 014_generation_feedback.sql records approve/reject signals per subtype for future few-shot improvement
  • Zero regression: v1 pipeline kept as automatic fallback; all 133 existing tests continue to pass

Test plan

  • 95 new unit tests across 5 new spec files (geometry builders, validator, vehicle generator, factory, scale estimation)
  • Full libs/ai test suite: 133/133 passing
  • libs/ai and apps/api build with zero TypeScript errors
  • End-to-end: upload car photo → verify GLB has body + torus wheels + glass windshield
  • End-to-end: upload bottle photo → verify cylinder body + tapered-cylinder neck
  • Confirm v1 fallback activates when Gemini returns malformed scene graph JSON

🤖 Generated with Claude Code

ofcskn and others added 2 commits May 18, 2026 16:04
Replaces the single-pass Gemini prompt + hardcoded template system with a
9-phase AI-driven pipeline that understands product structure semantically
before generating any geometry.

**Core changes**
- `SceneGraph` type replaces flat `ShapeParams` as the central data model;
  each part has its own shape, dimensions, position, rotation, and per-part
  PBR material including glass transmission and emissive support
- 4 new geometry primitives in `glb-builder.ts`: `torus` (wheels),
  `frustum` (car hood/roof), `tapered-cylinder` (bottle necks),
  `extruded-ellipse` (car body cross-section)
- `sceneGraphToPartDefs()` converts the v2 scene graph to `PartDef[]` with
  automatic symmetry mirroring (`symmetryMirror: "x" | "z"`)

**9-phase orchestrator (gemini-3d-generator.ts)**
- Phase A: `GeminiProductUnderstandingAnalyzer` — part-level structural analysis
- Phase B: `GeminiGeometryClassifier` — tessellation and shading rules
- Phase C: `GeminiSceneGraphReconstructor` — multi-view 3D reconstruction
- Phase D: topology-aware GLB encoding via `sceneGraphToPartDefs`
- Phase E: category correctors — `VehicleGenerator`, `ElectronicsGenerator`,
  `FurnitureGenerator`, `PackagingGenerator`, `ClothingGenerator`,
  `JewelryGenerator` via `CategoryGeneratorFactory`
- Phase F: `GeminiPbrMaterialAnalyzer` — per-part color sampling from images
- Phase G: `getStaticScaleBounds` — 25+ product-type size priors
- Phase H: `SceneGraphValidator` + `autoRepairSceneGraph` + `GlbValidator`
- Phase I: `GenerationFeedbackService` + migration 014 for approval/rejection signals

v1 (convert-2d-to-3d) kept as automatic fallback; zero regression in existing
test suite (133 tests pass).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ofcskn ofcskn merged commit 68c6ef9 into development May 18, 2026
1 check failed
@ofcskn ofcskn deleted the feature/glb-pipeline-v2-scene-graph branch May 18, 2026 13:09
ofcskn added a commit that referenced this pull request May 19, 2026
feat(ai): GLB pipeline v2 — semantic scene graph architecture
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant