|
|
2 bulan lalu | |
|---|---|---|
| .. | ||
| app | 3 bulan lalu | |
| components | 3 bulan lalu | |
| lib | 3 bulan lalu | |
| .env.example | 3 bulan lalu | |
| CHANGELOG.md | 3 bulan lalu | |
| README.md | 2 bulan lalu | |
| eslint.config.js | 3 bulan lalu | |
| next.config.ts | 3 bulan lalu | |
| package.json | 3 bulan lalu | |
| postcss.config.mjs | 3 bulan lalu | |
| tsconfig.json | 3 bulan lalu | |
A 3D scene editor and lightweight game runtime built with json-render, React Three Fiber, and Rapier physics. Edit levels as structured objects, preview them on a canvas, then press play for first/third-person movement, physics, health/damage, NPCs, and optional AI-assisted editing.
Spec via sceneToSpec, then rendered with ThreeRenderer and the @json-render/react-three-fiber registry.addObject, updateObjectTransform, etc.).GameCharacter components support AI-generated dialogue, with optional ElevenLabs text-to-speech.pnpm install # from the monorepo root
cd examples/game-engine
cp .env.example .env
Set the required environment variables:
| Variable | Required | Description |
|---|---|---|
AI_GATEWAY_API_KEY |
Yes | Vercel AI Gateway key |
AI_GATEWAY_MODEL |
No | Defaults to anthropic/claude-sonnet-4-6 |
ELEVENLABS_API_KEY |
No | Enables text-to-speech for NPC dialogue |
KV_REST_API_URL |
No | Upstash Redis URL for rate limiting |
KV_REST_API_TOKEN |
No | Upstash Redis token |
RATE_LIMIT_PER_MINUTE |
No | Defaults to 10 |
RATE_LIMIT_PER_DAY |
No | Defaults to 100 |
Model/environment uploads require Vercel Blob configuration when deployed.
pnpm dev
# http://game-engine-demo.json-render.localhost:1355
Requires global portless. The predev script checks for it automatically.
app/page.tsx -- mounts GameEnginecomponents/game-engine.tsx -- main shell: R3F canvas, sidebars, play/edit mode toggle, AI prompt integrationcomponents/game/ -- game primitives (GameBox, GameSphere, Player, GameCharacter, etc.) with physics and interactionscomponents/editor/ -- editor UI: object inspector, scene tree, AI prompt sidebar, gizmo controlscomponents/hud/ -- in-game HUD: health bar, crosshair, in-game AI promptapp/api/ai/route.ts -- streams YAML scene edits from the modelapp/api/ai-game/route.ts -- streams JSONL function calls for in-game AI manipulationapp/api/character-responses/route.ts -- generates NPC dialogue, optionally with TTSlib/catalog.ts -- 3D component catalog (R3F base + game-specific primitives)lib/registry.tsx -- maps catalog types to R3F and game componentslib/store.ts -- Zustand store for scenes, selection, play mode, health, undo/redolib/scene-to-spec.ts / lib/spec-to-scene.ts -- converts between the editor's scene graph and json-render specs