Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧊 Flash-3D: 3D Modeling Studio & API for Coding Agents

Flash-3D is a simplified, high-performance 3D modeling server built on Three.js, tailored specifically for autonomous coding agents (and human inspection).

Instead of navigating Blender's steep UI or complex Python bpy scripts, agents interact through one single unified API that takes an action enum and its arguments, and returns output in a guaranteed fixed shape with real-time spatial bounding feedback.


🌟 Key Features

  • Single Unified API (POST /api/action & POST /api/batch):
    • Takes { "action": "ACTION_NAME", "params": { ... } }.
    • Guaranteed fixed response shape on every call: success, action, targetId, message, data, error, sceneSummary, and executionTimeMs.
    • Instant spatial awareness: sceneSummary.bounds gives the agent exact min/max/size extents of all objects, eliminating spatial guesswork!
  • Sufficient to Model Virtually Any Shape:
    • 11 3D Primitives: Box, Sphere, Cylinder, Cone, Torus, Torus Knot, Capsule, Plane, Circle, Ring, Polyhedron.
    • 2D-to-3D Profile Modeling: EXTRUDE_SHAPE (with holes and bevels) and LATHE_SHAPE (360° curve revolution).
    • Constructive Solid Geometry (CSG): BOOLEAN_UNION, BOOLEAN_SUBTRACT, and BOOLEAN_INTERSECT powered by three-bvh-csg.
    • Parametric Modifiers: ARRAY_MODIFIER, ALIGN_OBJECT (auto-ground to floor Y=0), DEFORM_MESH (twist, bend, taper, wave, noise), SUBDIVIDE_MESH.
    • PBR Materials, External Textures & Procedural Shaders: Colors, roughness, metalness, transparency, emission glow, external image textures (PNG, JPEG/JPG, URLs, Base64 data URIs) with full UV repeat/offset/rotation controls and PBR channel maps (normalMap, roughnessMap, metalnessMap, emissiveMap, bumpMap, aoMap, alphaMap), plus built-in procedural textures (checkerboard, stripes, grid, noise, wood grain, brick, dots).
  • Real-Time Web UI Viewport (http://localhost:3001):
    • Interactive WebGL canvas with soft shadows, OrbitControls, and Transform gizmos (Move, Rotate, Scale).
    • Live Outliner tree and scene statistics (vertices, triangles, bounds).
    • Live Object Inspector with color picker, roughness, metalness, procedural textures, and image texture file upload/path inputs with drag-and-drop support.
    • Interactive Agent Console with JSON editor and pre-loaded recipe templates.
    • Action History log showing incoming agent calls in real time.
  • Import & Export in Standard 3D Formats:
    • Export: GLTF (.gltf), GLB binary (.glb), Wavefront OBJ (.obj), STL 3D Print (.stl), and Scene JSON (.json).
    • Import: Drag-and-drop or upload .obj, ASCII/binary .stl, or Three.js Object .json. glTF/GLB are export formats; server import is not implemented.
  • Ultra-Compact Agent Documentation (AGENT_API_REFERENCE.md):
    • High-density, token-efficient reference ready to be fed directly into coding agents (Claude, Gemini, GPT, DeepSeek).

🚀 Quick Start

1. Start the Server

npm start

The server will start on port 3001:

  • Web UI: http://localhost:3001
  • Action API: POST http://localhost:3001/api/action
  • Batch API: POST http://localhost:3001/api/batch
  • Agent Docs: GET http://localhost:3001/api/docs

📡 API Contract

Request Shape

{
  "action": "CREATE_BOX",
  "params": {
    "id": "pedestal",
    "width": 2,
    "height": 0.5,
    "depth": 2,
    "material": { "preset": "stone" },
    "alignY": "ground"
  }
}

Guaranteed Fixed Response Shape

{
  "success": true,
  "action": "CREATE_BOX",
  "targetId": "pedestal",
  "message": "Box 'pedestal' created successfully.",
  "data": { "id": "pedestal" },
  "error": null,
  "suggestion": null,
  "sceneSummary": {
    "objectCount": 1,
    "totalVertices": 24,
    "totalTriangles": 12,
    "bounds": {
      "min": [-1, 0, -1],
      "max": [1, 0.5, 1],
      "size": [2, 0.5, 2]
    },
    "objects": [
      {
        "id": "pedestal",
        "type": "Mesh",
        "geometryType": "BoxGeometry",
        "position": [0, 0.25, 0],
        "rotation": [0, 0, 0],
        "scale": [1, 1, 1],
        "bounds": { "min": [-1, 0, -1], "max": [1, 0.5, 1], "center": [0, 0.25, 0], "size": [2, 0.5, 2] },
        "color": "#7a7a7a"
      }
    ]
  },
  "executionTimeMs": 4
}

🛠️ Python Client Example for AI Agents

Any coding agent can easily model using Python:

import requests

# 1. Connect and build a coffee mug with CSG Difference and Torus Union in 1 call:
payload = {
    "actions": [
        {"action": "CLEAR_SCENE"},
        {"action": "CREATE_CYLINDER", "params": {"id": "outer", "radiusTop": 1.2, "radiusBottom": 1.0, "height": 2.5, "material": {"color": "#ffffff"}}},
        {"action": "CREATE_CYLINDER", "params": {"id": "inner", "radiusTop": 1.05, "radiusBottom": 0.85, "height": 2.6, "transform": {"position": [0, 0.2, 0]}}},
        {"action": "BOOLEAN_SUBTRACT", "params": {"id": "cup_body", "targetA": "outer", "targetB": "inner", "material": {"color": "#ffffff"}}},
        {"action": "CREATE_TORUS", "params": {"id": "handle", "radius": 0.7, "tube": 0.18, "arc": 260, "material": {"color": "#ffffff"}, "transform": {"position": [1.2, 0, 0], "rotation": [0, 0, 90]}}},
        {"action": "BOOLEAN_UNION", "params": {"id": "coffee_mug", "targetA": "cup_body", "targetB": "handle"}},
        {"action": "ALIGN_OBJECT", "params": {"id": "coffee_mug", "ground": True}}
    ]
}

res = requests.post("http://localhost:3000/api/batch", json=payload).json()
print("Success:", res["success"])
print("New Object Bounds:", res["sceneSummary"]["bounds"])

# 2. Download the GLTF model:
gltf = requests.get("http://localhost:3000/api/export/gltf").text
with open("coffee_mug.gltf", "w") as f:
    f.write(gltf)

📚 Agent Documentation

The compact API specification for LLM prompts is located at AGENT_API_REFERENCE.md

About

Flash-3d: Agent-first 3D modeling

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages