createAction
Add interactive actions to Spline 3D scenes by creating transitions, animations, sound effects, camera controls, and object behaviors triggered by events.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sceneId | Yes | Scene ID | |
| eventId | Yes | Event ID to attach this action to | |
| type | Yes | Action type | |
| name | Yes | Action name | |
| target | No | Target ID (object, state, camera, etc.) | |
| parameters | No | Action parameters |
Implementation Reference
- src/tools/action-tools.js:25-55 (handler)The main handler function that executes the createAction tool by constructing action data and sending a POST request to the Spline API endpoint to create a new action attached to the specified event.async ({ sceneId, eventId, type, name, target, parameters }) => { try { const actionData = { type, name, ...(target && { target }), ...(parameters && { parameters }), }; const result = await apiClient.request('POST', `/scenes/${sceneId}/events/${eventId}/actions`, actionData); return { content: [ { type: 'text', text: `Action "${name}" created successfully with ID: ${result.id}` } ] }; } catch (error) { return { content: [ { type: 'text', text: `Error creating action: ${error.message}` } ], isError: true }; } }
- src/tools/action-tools.js:12-24 (schema)Zod schema defining the input parameters and validation for the createAction tool.{ sceneId: z.string().min(1).describe('Scene ID'), eventId: z.string().min(1).describe('Event ID to attach this action to'), type: z.enum([ 'transition', 'sound', 'video', 'openLink', 'resetScene', 'switchCamera', 'createObject', 'destroyObject', 'sceneTransition', 'animation', 'particlesControl', 'variableControl', 'conditional', 'setVariable', 'clearLocalStorage', 'apiRequest' ]).describe('Action type'), name: z.string().min(1).describe('Action name'), target: z.string().optional().describe('Target ID (object, state, camera, etc.)'), parameters: z.record(z.any()).optional().describe('Action parameters'), },
- src/tools/action-tools.js:10-56 (registration)The server.tool call that registers the createAction tool with its schema and handler within the registerActionTools function.server.tool( 'createAction', { sceneId: z.string().min(1).describe('Scene ID'), eventId: z.string().min(1).describe('Event ID to attach this action to'), type: z.enum([ 'transition', 'sound', 'video', 'openLink', 'resetScene', 'switchCamera', 'createObject', 'destroyObject', 'sceneTransition', 'animation', 'particlesControl', 'variableControl', 'conditional', 'setVariable', 'clearLocalStorage', 'apiRequest' ]).describe('Action type'), name: z.string().min(1).describe('Action name'), target: z.string().optional().describe('Target ID (object, state, camera, etc.)'), parameters: z.record(z.any()).optional().describe('Action parameters'), }, async ({ sceneId, eventId, type, name, target, parameters }) => { try { const actionData = { type, name, ...(target && { target }), ...(parameters && { parameters }), }; const result = await apiClient.request('POST', `/scenes/${sceneId}/events/${eventId}/actions`, actionData); return { content: [ { type: 'text', text: `Action "${name}" created successfully with ID: ${result.id}` } ] }; } catch (error) { return { content: [ { type: 'text', text: `Error creating action: ${error.message}` } ], isError: true }; } } );
- src/index.js:95-95 (registration)The call to registerActionTools(server) in the main server setup, which includes registering the createAction tool.registerActionTools(server);