configureGradientLayer
Configure gradient layers in 3D scenes by setting gradient types, colors, positions, rotation, and scale for materials in Spline designs.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sceneId | Yes | Scene ID | |
| materialId | Yes | Material ID | |
| layerId | Yes | Layer ID | |
| gradientType | Yes | Gradient type | |
| colors | Yes | Gradient colors | |
| rotation | No | Rotation in degrees | |
| scale | No | Gradient scale |
Implementation Reference
- The handler function for the 'configureGradientLayer' tool. It constructs layer parameters from inputs and sends a PUT request to the API endpoint to update the gradient layer on the specified material.async ({ sceneId, materialId, layerId, gradientType, colors, rotation, scale }) => { try { const layerParams = { gradientType, colors, ...(rotation !== undefined && { rotation }), ...(scale !== undefined && { scale }), }; await apiClient.request('PUT', `/scenes/${sceneId}/materials/${materialId}/layers/${layerId}`, { params: layerParams }); return { content: [ { type: 'text', text: `Gradient layer ${layerId} configured successfully` } ] }; } catch (error) { return { content: [ { type: 'text', text: `Error configuring gradient layer: ${error.message}` } ], isError: true }; } }
- Zod input schema for the 'configureGradientLayer' tool, validating parameters like sceneId, materialId, layerId, gradientType, colors array, rotation, and scale.{ sceneId: z.string().min(1).describe('Scene ID'), materialId: z.string().min(1).describe('Material ID'), layerId: z.string().min(1).describe('Layer ID'), gradientType: z.enum(['linear', 'radial', 'angular']).describe('Gradient type'), colors: z.array(z.object({ color: z.string().describe('Color value (hex, rgb, or rgba)'), position: z.number().min(0).max(1).describe('Position in gradient (0-1)'), })).min(2).describe('Gradient colors'), rotation: z.number().optional().default(0).describe('Rotation in degrees'), scale: z.number().optional().default(1).describe('Gradient scale'), },
- src/tools/advanced-material-tools.js:251-297 (registration)Registration of the 'configureGradientLayer' tool via server.tool() within the registerAdvancedMaterialTools function.'configureGradientLayer', { sceneId: z.string().min(1).describe('Scene ID'), materialId: z.string().min(1).describe('Material ID'), layerId: z.string().min(1).describe('Layer ID'), gradientType: z.enum(['linear', 'radial', 'angular']).describe('Gradient type'), colors: z.array(z.object({ color: z.string().describe('Color value (hex, rgb, or rgba)'), position: z.number().min(0).max(1).describe('Position in gradient (0-1)'), })).min(2).describe('Gradient colors'), rotation: z.number().optional().default(0).describe('Rotation in degrees'), scale: z.number().optional().default(1).describe('Gradient scale'), }, async ({ sceneId, materialId, layerId, gradientType, colors, rotation, scale }) => { try { const layerParams = { gradientType, colors, ...(rotation !== undefined && { rotation }), ...(scale !== undefined && { scale }), }; await apiClient.request('PUT', `/scenes/${sceneId}/materials/${materialId}/layers/${layerId}`, { params: layerParams }); return { content: [ { type: 'text', text: `Gradient layer ${layerId} configured successfully` } ] }; } catch (error) { return { content: [ { type: 'text', text: `Error configuring gradient layer: ${error.message}` } ], isError: true }; } } );