[Enhancement] Chess: user-generated piece models via Trellis3D pipeline #71

Open
opened 2026-05-05 20:19:56 +00:00 by spikerj · 0 comments
Owner

Summary

Allow users to generate custom 3D chess piece models using the existing Trellis3D (image → GLB) pipeline and use them in place of the default static piece set.

Depends on

  • #40 — Chess Three.js display must land first; it introduces the ChessPieceModelProvider injection token abstraction that this feature plugs into.

Background

The chess 3D renderer (#40) introduces a ChessPieceModelProvider interface with an InjectionToken. The default StaticChessPieceModelProvider loads GLTF models from local assets. This ticket adds a second provider implementation — Trellis3dChessPieceModelProvider — that loads user-generated GLB models from the Trellis3D backend via ThreeDGeneratorService.getDownloadUrl().

The Trellis3D pipeline already supports:

  • Image upload → RabbitMQ → TRELLIS worker → GLB output
  • GET /api/threedmodel/{id}/download (authenticated, streams GLB)
  • ThreeDGeneratorService on the Angular side with GLTFLoader consumption

Scope

New: "Piece Set" concept

  • A piece set is a collection of 6 ThreeDModel IDs (one per piece type: king, queen, rook, bishop, knight, pawn).
  • Users create a piece set by uploading 6 images (one per piece type) or optionally via text prompts (requires extending SourceType.Text in the Trellis worker).
  • Piece sets are persisted per user — new Mongo entity or sub-document on user profile.

New: Trellis3dChessPieceModelProvider

  • Implements ChessPieceModelProvider interface from #40.
  • loadPrototype(type, color) calls ThreeDGeneratorService.getDownloadUrl(modelId) → authenticated fetch → blob URL → GLTFLoader.load().
  • Handles color tinting (white/black) on the loaded model's materials.
  • Falls back to StaticChessPieceModelProvider if any model in the set is still generating, failed, or missing.

New: UI for piece set management

  • Chess settings panel gains a "Piece Set" section.
  • Options: Default (static) | Custom (user-generated).
  • Custom flow: upload 6 images, preview each as it generates (real-time progress via existing SignalR Receive3DModelProgress), save set.
  • The component-level providers array swaps CHESS_PIECE_MODEL_PROVIDER based on user selection.

Backend considerations

  • Auth caveat: GLTFLoader (Three.js FileLoader) does not pass Angular HttpClient interceptors. The provider must fetch the GLB as an authenticated blob and create an object URL, or configure a custom Three.js loader with setRequestHeader.
  • Extend ThreeDModel entity if chess-specific metadata is needed (e.g., chessPieceType field).

Acceptance criteria

  • Users can generate a complete custom 6-piece set from uploaded images.
  • Generated pieces render correctly in the 3D chess board with proper scale, orientation, and color tinting.
  • Progress updates display in real-time during generation.
  • Graceful fallback to default pieces if generation is incomplete or fails.
  • Piece set selection persists across sessions.
  • No regression to default static piece set behavior.

References

  • ChessPieceModelProvider interface: introduced in #40
  • Trellis3D service: spikersoft-backend/SpikerSoft.EventHandlers.Trellis3D.Python/
  • Angular service: libraries/tools/src/services/threed-generator/threed-generator.service.ts
  • Backend API: SpikerSoft.Api/Domain/ThreeDModel/ThreeDModelController.cs
## Summary Allow users to generate custom 3D chess piece models using the existing Trellis3D (image → GLB) pipeline and use them in place of the default static piece set. ## Depends on - **#40** — Chess Three.js display must land first; it introduces the `ChessPieceModelProvider` injection token abstraction that this feature plugs into. ## Background The chess 3D renderer (#40) introduces a `ChessPieceModelProvider` interface with an `InjectionToken`. The default `StaticChessPieceModelProvider` loads GLTF models from local assets. This ticket adds a second provider implementation — `Trellis3dChessPieceModelProvider` — that loads user-generated GLB models from the Trellis3D backend via `ThreeDGeneratorService.getDownloadUrl()`. The Trellis3D pipeline already supports: - Image upload → RabbitMQ → TRELLIS worker → GLB output - `GET /api/threedmodel/{id}/download` (authenticated, streams GLB) - `ThreeDGeneratorService` on the Angular side with `GLTFLoader` consumption ## Scope ### New: "Piece Set" concept - A piece set is a collection of 6 `ThreeDModel` IDs (one per piece type: king, queen, rook, bishop, knight, pawn). - Users create a piece set by uploading 6 images (one per piece type) or optionally via text prompts (requires extending `SourceType.Text` in the Trellis worker). - Piece sets are persisted per user — new Mongo entity or sub-document on user profile. ### New: `Trellis3dChessPieceModelProvider` - Implements `ChessPieceModelProvider` interface from #40. - `loadPrototype(type, color)` calls `ThreeDGeneratorService.getDownloadUrl(modelId)` → authenticated fetch → blob URL → `GLTFLoader.load()`. - Handles color tinting (white/black) on the loaded model's materials. - Falls back to `StaticChessPieceModelProvider` if any model in the set is still generating, failed, or missing. ### New: UI for piece set management - Chess settings panel gains a "Piece Set" section. - Options: Default (static) | Custom (user-generated). - Custom flow: upload 6 images, preview each as it generates (real-time progress via existing SignalR `Receive3DModelProgress`), save set. - The component-level `providers` array swaps `CHESS_PIECE_MODEL_PROVIDER` based on user selection. ### Backend considerations - **Auth caveat**: `GLTFLoader` (Three.js `FileLoader`) does not pass Angular `HttpClient` interceptors. The provider must fetch the GLB as an authenticated blob and create an object URL, or configure a custom Three.js loader with `setRequestHeader`. - Extend `ThreeDModel` entity if chess-specific metadata is needed (e.g., `chessPieceType` field). ## Acceptance criteria - [ ] Users can generate a complete custom 6-piece set from uploaded images. - [ ] Generated pieces render correctly in the 3D chess board with proper scale, orientation, and color tinting. - [ ] Progress updates display in real-time during generation. - [ ] Graceful fallback to default pieces if generation is incomplete or fails. - [ ] Piece set selection persists across sessions. - [ ] No regression to default static piece set behavior. ## References - `ChessPieceModelProvider` interface: introduced in #40 - Trellis3D service: `spikersoft-backend/SpikerSoft.EventHandlers.Trellis3D.Python/` - Angular service: `libraries/tools/src/services/threed-generator/threed-generator.service.ts` - Backend API: `SpikerSoft.Api/Domain/ThreeDModel/ThreeDModelController.cs`
Sign in to join this conversation.