feat: Add AI-powered custom building generation with fal.ai#329
Open
blendi-remade wants to merge 13 commits intoamilich:mainfrom
Open
feat: Add AI-powered custom building generation with fal.ai#329blendi-remade wants to merge 13 commits intoamilich:mainfrom
blendi-remade wants to merge 13 commits intoamilich:mainfrom
Conversation
- Generate custom building sprites using fal.ai nano-banana-pro - Analyze buildings with vision LLM for game attributes (cost, jobs, pollution, etc.) - Smart aspect ratio selection based on building description - Client-side content bounds detection for precise isometric placement - Fal-branded UI with spinning logo and loading states - Full bulldoze support for multi-tile custom buildings
Contributor
|
@blendi-remade is attempting to deploy a commit to the andrew-4640's projects Team on Vercel. A member of the Team first needs to authorize it. |
- Introduce valid aspect ratios for building generation to ensure consistency - Validate aspect ratio input from the client and fallback to default if invalid - Remove deprecated background removal functions to streamline image processing - Implement validation for custom building properties to prevent errors - Update sidebar tool selection logic for improved user experience - Apply AI-analyzed environmental stats to custom buildings in the game context
…enerator - Added crossOrigin attribute to the image element to support loading images from external fal.ai CDN URLs, ensuring proper image retrieval and display.
…tom buildings - Update pollution and landValue assignments to apply only to the origin tile, aligning behavior with regular building logic.
- Modify the footprint validation logic to only allow placement on grass tiles, clarifying that 'empty' tiles are part of multi-tile building footprints and not truly empty.
…analysis - Implement a try-catch block around getImageData to manage potential SecurityError on CORS-tainted canvases, providing a fallback to assume full image content bounds if an error occurs.
- Update population and jobs assignments to use nullish coalescing, ensuring default values are applied when stats are undefined.
- Modify the footprint validation logic to allow placement on both grass and tree tiles, aligning with multi-tile building behavior.
- Remove the analyzing step from the CustomBuildingPanel, streamlining the user experience. - Update the reset logic to only consider the generating step, enhancing modal behavior.
- Update content width and height calculations to include an additional pixel, ensuring accurate content bounds analysis for image rendering.
- Update the logic to use customSize for buildings of type 'custom', ensuring accurate size determination for building placement in the isometric grid.
- Update the size calculation to utilize customSize for buildings of type 'custom', ensuring accurate placement and rendering in the isometric grid.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
Adds an experimental AI custom building pipeline backed by
fal.ai, including a newPOST /api/generate-buildingroute that (1) chooses an aspect ratio via Gemini, (2) generates an isometric sprite via Nano Banana Pro, (3) removes the background via Bria RMBG, and (4) analyzes the sprite via vision LLM to derive in-game attributes (size/cost/pop/jobs/pollution/land value).Introduces a full client UX + persistence flow:
CustomBuildingPanelin the sidebar to create/list/remove/select custom buildings,CustomBuildingsProviderto store them inlocalStorage, and game/runtime support to place, render, select, and bulldoze multi-tilecustombuildings (including content-bounds centering and external-image CORS handling inimageLoader). Documentation and dependencies are updated (@fal-ai/client, README setup viaFAL_KEY).Medium Risk. Adds new server API integration with external AI services and introduces a new building type that affects placement/rendering/bulldoze paths, which could impact core gameplay flows if misbehaving.
Written by Cursor Bugbot for commit a9e9966. This will update automatically on new commits. Configure here.