adachsoft / blender-tool
Blender tools for building, inspecting, rendering, and exporting 3D scenes through the Blender Agent API.
Requires
- php: ^8.3
- adachsoft/ai-tool-call: ^2.3
- guzzlehttp/guzzle: ^7
Requires (Dev)
- adachsoft/php-code-style: ^0.7.3
- friendsofphp/php-cs-fixer: ^3.95
- phpstan/phpstan: ^2.3
- phpunit/phpunit: ^13.4
- rector/rector: ^2.8
- symplify/phpstan-rules: ^14.19
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
adachsoft/blender-tool provides SPI-compatible tools for building and inspecting 3D scenes through the remote Blender Agent API. It supports workspace creation, file uploads, Blender Python scene updates, scene inspection, rendering, and GLB export. Blender runs in the remote service; this library does not launch Blender, execute shell commands, or require a shared filesystem.
Requirements
- PHP 8.3 or later.
- Composer.
Installation
Install the library with Composer:
composer require adachsoft/blender-tool
Usage
Create a ConfigMap from your application settings, then pass it to one of the tool factories. See the configuration and available tools below.
Configuration
Each tool factory reads its configuration from the ConfigMap passed to create():
| Key | Type | Required | Default | Description |
|---|---|---|---|---|
base_url | string | Yes | — | Root URL of the Blender service. Must use HTTP or HTTPS. |
api_token | string | Yes | — | Non-empty bearer token sent in the Authorization header. |
timeout_seconds | integer | No | 300 | Positive maximum duration for each HTTP request. |
base_path | string | Yes | — | Agent project root reserved for project-file operations. |
Provide the token through your application's secret configuration mechanism:
use AdachSoft\AiToolCall\SPI\Collection\ConfigMap;
$config = new ConfigMap([
'base_url' => 'https://blender.example.com',
'api_token' => $secretToken,
'timeout_seconds' => 300,
'base_path' => '/workspace/project',
]);
The service is accessed only over HTTP; files are transferred through HTTP endpoints rather than a shared mount.
Available tools
blender_workspace_createcreates a workspace and returns itsworkspace_id.blender_file_uploaduploads a reference image or other project file to a workspace. Blender scripts can open uploaded files by name from their working directory.blender_scene_applyruns Blender Python (bpy) against the workspace's saved scene and returns execution status and output details. The service saves the scene only when the script succeeds.blender_scene_inforeturns the saved scene's objects, polygon count, and bounds.blender_renderrenders workspace views and returns images for visual inspection.blender_exportexports the workspace as a GLB file to a project-relative path. Existing files are preserved unlessoverwriteis set totrue.
Each tool has a factory that validates its configuration and creates a Guzzle-backed API client. Project-file tools restrict paths to the configured base_path.