Skip to content

Feat/jarvis 3d scene generation#1916

Open
josemguerrajmg-oss wants to merge 5 commits into
MemTensor:mainfrom
josemguerrajmg-oss:feat/jarvis-3d-scene-generation
Open

Feat/jarvis 3d scene generation#1916
josemguerrajmg-oss wants to merge 5 commits into
MemTensor:mainfrom
josemguerrajmg-oss:feat/jarvis-3d-scene-generation

Conversation

@josemguerrajmg-oss

@josemguerrajmg-oss josemguerrajmg-oss commented Jun 12, 2026

Copy link
Copy Markdown

What this adds

1. AI 3D scene generation (local Ollama)

A new Scene mode in the Jarvis HUD: describe a 3D composition in plain
language ("a glowing orb surrounded by orbiting violet rings") and it renders
live in Three.js — no cloud API key required.

  • Calls local Ollama with format: "json" (constrained decoding) so small
    models reliably return parseable scene JSON
  • Auto-discovers an installed chat model; filters out embedding-only models
  • Every field is coerced/clamped so one bad value can't break the render
  • Defers the mode switch until the scene is ready, with actionable errors
    ("Ollama not running. Start it with: ollama serve")

2. Universal 3D model import

The importer was GLB/GLTF-only, so STL and other formats silently failed.
Now supports GLB, GLTF, STL, OBJ, FBX, PLY, DAE, 3MF.

  • Geometry-only formats (STL/PLY) get a clean metallic material; PLY keeps
    vertex colors
  • Each loader is dynamically imported → its own lazy chunk, lean main bundle
  • Unsupported extensions show a clear "Supported: ..." message
  • Loads report progress, auto-center/scale to fit, and dispose previous models

Verification

  • tsc --noEmit clean
  • vite build clean (7 separate loader chunks emitted)
  • Scene generation tested against live Ollama (llama3.2) — 4 prompts, all valid
  • STL/OBJ/PLY parsers confirmed on real geometry via node smoke test

Jose Guerra and others added 5 commits June 11, 2026 22:51
Adds a new 'scene' mode to the Jarvis HUD where users can describe a 3D
composition in natural language and see it rendered live in Three.js. The
scene generation pipeline calls a local Ollama instance (llama3.2) so
no cloud API key is required for this feature.

Changes:
- shared/types/jarvis.ts: add 'scene' JarvisMode and 'create_scene' command type
- command-parser.ts: detect create/generate/make/build + 3D keywords → create_scene intent
- Jarvis.tsx:
  - SceneDescriptor type + callLocalLLMForScene (Ollama /api/chat)
  - buildSceneFromDescriptor: maps JSON objects to Three.js meshes (sphere/box/torus/
    cylinder/cone/icosahedron/ring/plane with full material support)
  - JarvisViewport: sceneGroup rendered procedurally, gentle rotation + float animation,
    camera positioned at 6.5z for composed scenes
  - executeCommand: create_scene branch routes to Ollama before standard Anthropic path
  - Context-aware chips for scene mode: Create new, Brand 3D, Product 3D
  - Mode badge, stateChips, and commandChips updated for 'scene'

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Switches 3D scene generation from Ollama (required separate install)
to the API key already stored in the app keychain. Users get scene
rendering as soon as they have an API key configured — no additional
setup required. Also widens the trigger regex to catch more natural
phrasings like "design a 3D brand mark" or "3D render of a product".

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…overy

Scene generation now calls local Ollama instead of the cloud API.
Automatically picks the best available model by querying /api/tags and
ranking against a preferred list (qwen2.5 > llama3.2 > llama3 > mistral
> phi4 > gemma3 > …). Falls back gracefully with actionable error
messages if Ollama isn't running or has no models installed.
No API key required for 3D scene generation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Root cause of broken scene generation: small local models (llama3.2 etc.)
regularly emit malformed JSON — e.g. a mismatched quote like "rotation':[…]
— which crashed JSON.parse and produced no scene. Verified against real
Ollama.

Fixes:
- Use Ollama "format":"json" constrained decoding — guarantees parseable
  JSON output every time. This is the core fix.
- Filter out embedding-only models (nomic-embed-text, *-minilm, bert
  families) so the fallback model picker never selects a model that can't
  chat.
- normalizeDescriptor(): coerce and clamp every field from the model so a
  single bad value can't break the render — type aliases (cube->box,
  orb->sphere), numeric range clamps, hex/CSS color validation, and
  opacity<->transparent coupling.
- Defensive JSON repair (smart quotes, single quotes, trailing commas) as
  a second line of defense.
- Wrap fetches in try/catch to surface a clean "ollama_down" instead of an
  unhandled rejection.
- Defer the scene-mode switch until meshes are ready so the user keeps
  seeing their current view during the multi-second generation instead of
  an empty void; actionable error messages for each failure mode.

Verified: tsc --noEmit clean, vite build succeeds (renderer bundle emitted),
and end-to-end generation against local Ollama renders valid scenes for
4 varied prompts.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The importer was hardcoded to GLTFLoader with an accept=".glb,.gltf"
file picker, so STL (and OBJ/FBX/PLY/DAE/3MF) files silently failed.

Adds a format-dispatching loader:
- glb/gltf  -> GLTFLoader
- stl       -> STLLoader  (geometry-only; wrapped in a metallic standard material)
- obj       -> OBJLoader
- fbx       -> FBXLoader
- ply       -> PLYLoader  (geometry-only; enables vertexColors when present)
- dae       -> ColladaLoader
- 3mf       -> ThreeMFLoader

Each loader is dynamically imported, so it builds into its own lazy
chunk and only downloads when that format is actually picked — the main
bundle stays lean.

Other changes:
- File picker now accepts all supported extensions.
- Unsupported extensions get a clear "Supported: ..." message instead of
  a silent failure.
- Loads now report progress in the transcript: "Loading file.stl..." ->
  "STL model loaded." or an actionable error, via an onModelResult callback.
- Loading a model auto-switches to object mode (where the model renders),
  centers and scales it to fit, and disposes the previous model's
  geometry/materials to avoid leaks.

Verified: tsc clean; vite build emits 7 separate loader chunks; and
STL/OBJ/PLY parsers confirmed to parse real geometry in a node smoke test.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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