CoolFace
Apppublic

venkat112/venkat_glb_creation

sourceHugging Faceupdated 8mo agoView on Hugging Face
0likes
App README

GLB Generation Engine

An AI-driven GLB Generation Engine with an integrated UI workflow that transforms text descriptions into complete 3D worlds.

Features

  • Natural Language Processing: Parse text descriptions and automatically generate 3D scenes
  • Complete Scene Generation: Creates GLB files with meshes, materials, lighting, avatars, animations, audio, and effects
  • Dual Generation Methods: Supports both Three.js and Blender Python generation
  • Comprehensive Output: Generates scene graph JSON, generation code, and debug reports
  • Modern UI: Beautiful web interface for uploading descriptions and downloading results
  • PBR Materials: Realistic physically-based rendering materials
  • Advanced Features: Supports fog, particles, emissive materials, animations, and spatial audio

Quick Start

Prerequisites

  1. 1.Node.js (v18+ recommended)
  2. 2.Blender (optional, for Blender-based generation)
  3. 3.Install Blender on your machine
  4. 4.On Windows, set the BLENDER_PATH environment variable:
powershell
     $env:BLENDER_PATH = "C:\Program Files\Blender Foundation\Blender 3.6\blender.exe"

Installation

bash
npm install

This will install:

  • Express (web server)
  • Three.js (for GLB generation)
  • GLTF Transform (for GLB processing)
  • Multer (for file uploads)
  • UUID (for unique IDs)

Running the Server

bash
node server.js

Or on Windows PowerShell:

powershell
.\start-server.ps1

The server will start on http://localhost:3000

Usage

Web UI

  1. 1.Open http://localhost:3000 in your browser
  2. 2.Enter a scene description in the text area, for example:
   Create a magical forest at night with glowing mushrooms, fog, fireflies, 
   a walking wizard avatar, blue ambient light, and soft background music.
  1. 1.Click "Generate GLB"
  2. 2.Wait for generation to complete
  3. 3.Download the generated files:
  4. 4.scene.glb - The 3D scene file
  5. 5.scene-graph.json - Structured scene graph
  6. 6.generation-code.js - Three.js generation code
  7. 7.generation-script.py - Blender Python script
  8. 8.debug-report.txt - Comprehensive debug report

API Usage

POST /generate

Generate a GLB from a text description or structured JSON.

Text Description:

bash
curl -X POST http://localhost:3000/generate \
  -H "Content-Type: application/json" \
  -d '{"description": "Create a magical forest at night with glowing mushrooms"}'

Structured JSON:

bash
curl -X POST http://localhost:3000/generate \
  -H "Content-Type: application/json" \
  -d @example_scene.json

Response:

json
{
  "success": true,
  "sceneName": "generated_scene",
  "id": "uuid-here",
  "files": {
    "glb": "/download/uuid/scene.glb",
    "sceneGraph": "/download/uuid/scene-graph.json",
    "codeJS": "/download/uuid/generation-code.js",
    "codePy": "/download/uuid/generation-script.py",
    "debug": "/download/uuid/debug-report.txt"
  },
  "summary": {
    "nodes": 15,
    "meshes": 8,
    "materials": 5,
    "lights": 2,
    "hasAvatar": true,
    "hasAudio": true,
    "hasEffects": true
  }
}
GET /download/:id/:filename

Download generated files.

bash
curl http://localhost:3000/download/uuid/scene.glb -o scene.glb

Scene Description Examples

Magical Forest

Create a magical forest at night with glowing mushrooms, fog, fireflies, 
a walking wizard avatar, blue ambient light, and soft background music.

Beach Scene

Create a sunny beach with palm trees, ocean water, sand, and a bright sun.

Sci-Fi Lab

Create a futuristic laboratory with metallic surfaces, bright lights, 
and a character standing in the center.

Desert Scene

Create a desert at sunset with sand dunes, rocks, and warm orange lighting.

Supported Features

Environments

  • Forest, Beach, Desert, City, Lab, Room, Space, Underwater, Magical

Objects

  • Trees, Mushrooms, Fire, Rocks, Water, Buildings, Vehicles, Fireflies

Lighting

  • Day, Night, Sunset, Sunrise, Indoor
  • Ambient, Directional, Point, Spot lights
  • Custom colors and intensities

Materials

  • Metal, Wood, Glass, Fabric, Stone
  • Glowing/Emissive materials
  • PBR (Physically Based Rendering)

Effects

  • Fog, Rain, Snow, Bloom, Particles

Audio

  • Ambient background music
  • Spatial/positional audio

Avatars

  • Humanoid avatars with rigging
  • Walking, standing, sitting animations
  • Customizable scale and position

Project Structure

glb_creation/
├── server.js                 # Express server with API endpoints
├── public/
├── scripts/
├── tmp/                      # Generated files (temporary)
├── package.json
└── README.md

Generation Pipeline

  1. 1.Parse Description: Text description → Structured scene data
  2. 2.Generate Scene Graph: Scene data → Scene graph JSON
  3. 3.Generate GLB:
  4. 4.Try Three.js generation first
  5. 5.Fallback to Blender if Three.js fails
  6. 6.Generate Code: Create Node.js and Python generation scripts
  7. 7.Generate Debug Report: Comprehensive analysis and recommendations
  8. 8.Return Files: All files available for download

API Endpoints

  • GET / - Web UI
  • GET /api/status - API status and capabilities
  • POST /generate - Generate GLB from description
  • GET /download/:id/:filename - Download generated files

Troubleshooting

Three.js Not Available

If Three.js generation fails, the system automatically falls back to Blender. Make sure Blender is installed and BLENDER_PATH is set.

GLB Not Generated

  • Check the debug report for detailed error information
  • Verify Blender is installed and accessible
  • Check server console for error messages

Port Already in Use

Change the port:

bash
PORT=3001 node server.js

Development

Adding New Object Types

Edit scripts/scene_parser.js to add new keywords and object creation logic.

Adding New Materials

Update the material detection in scene_parser.js and material creation in both glb_generator_threejs.js and generate_scene.py.

Customizing UI

Edit public/index.html to customize the web interface.

License

ISC

Contributing

Contributions welcome! Please ensure all code follows the existing style and includes appropriate error handling.