updateMaterial
Modify material properties in 3D scenes including color, roughness, metalness, opacity, and shading parameters to customize visual appearance and surface characteristics.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sceneId | Yes | Scene ID | |
| materialId | Yes | Material ID | |
| color | No | Base color (hex) | |
| roughness | No | Surface roughness (0-1) | |
| metalness | No | Metalness factor (0-1) | |
| opacity | No | Opacity (0-1) | |
| transparent | No | Whether the material is transparent | |
| wireframe | No | Whether to render as wireframe | |
| emissive | No | Emissive color (hex) | |
| emissiveIntensity | No | Intensity of emission | |
| side | No | Which side to render | |
| flatShading | No | Use flat shading | |
| properties | No | Additional properties |
Implementation Reference
- src/tools/material-tools.js:175-226 (handler)The MCP tool handler for 'updateMaterial' that processes inputs, builds update payload, invokes the API client, and returns formatted response.async ({ sceneId, materialId, color, roughness, metalness, opacity, transparent, wireframe, emissive, emissiveIntensity, side, flatShading, properties }) => { try { const updateData = { ...(color && { color }), ...(roughness !== undefined && { roughness }), ...(metalness !== undefined && { metalness }), ...(opacity !== undefined && { opacity }), ...(transparent !== undefined && { transparent }), ...(wireframe !== undefined && { wireframe }), ...(emissive && { emissive }), ...(emissiveIntensity !== undefined && { emissiveIntensity }), ...(side && { side }), ...(flatShading !== undefined && { flatShading }), ...(properties && { properties }), }; await apiClient.updateMaterial(sceneId, materialId, updateData); return { content: [ { type: 'text', text: `Material ${materialId} updated successfully` } ] }; } catch (error) { return { content: [ { type: 'text', text: `Error updating material: ${error.message}` } ], isError: true }; } }
- src/tools/material-tools.js:160-174 (schema)Zod input schema for the 'updateMaterial' tool parameters.{ sceneId: z.string().min(1).describe('Scene ID'), materialId: z.string().min(1).describe('Material ID'), color: z.string().optional().describe('Base color (hex)'), roughness: z.number().min(0).max(1).optional().describe('Surface roughness (0-1)'), metalness: z.number().min(0).max(1).optional().describe('Metalness factor (0-1)'), opacity: z.number().min(0).max(1).optional().describe('Opacity (0-1)'), transparent: z.boolean().optional().describe('Whether the material is transparent'), wireframe: z.boolean().optional().describe('Whether to render as wireframe'), emissive: z.string().optional().describe('Emissive color (hex)'), emissiveIntensity: z.number().min(0).optional().describe('Intensity of emission'), side: z.enum(['front', 'back', 'double']).optional().describe('Which side to render'), flatShading: z.boolean().optional().describe('Use flat shading'), properties: z.record(z.any()).optional().describe('Additional properties'), },
- src/tools/material-tools.js:158-227 (registration)MCP server registration of the 'updateMaterial' tool using server.tool(name, inputSchema, handlerFn).server.tool( 'updateMaterial', { sceneId: z.string().min(1).describe('Scene ID'), materialId: z.string().min(1).describe('Material ID'), color: z.string().optional().describe('Base color (hex)'), roughness: z.number().min(0).max(1).optional().describe('Surface roughness (0-1)'), metalness: z.number().min(0).max(1).optional().describe('Metalness factor (0-1)'), opacity: z.number().min(0).max(1).optional().describe('Opacity (0-1)'), transparent: z.boolean().optional().describe('Whether the material is transparent'), wireframe: z.boolean().optional().describe('Whether to render as wireframe'), emissive: z.string().optional().describe('Emissive color (hex)'), emissiveIntensity: z.number().min(0).optional().describe('Intensity of emission'), side: z.enum(['front', 'back', 'double']).optional().describe('Which side to render'), flatShading: z.boolean().optional().describe('Use flat shading'), properties: z.record(z.any()).optional().describe('Additional properties'), }, async ({ sceneId, materialId, color, roughness, metalness, opacity, transparent, wireframe, emissive, emissiveIntensity, side, flatShading, properties }) => { try { const updateData = { ...(color && { color }), ...(roughness !== undefined && { roughness }), ...(metalness !== undefined && { metalness }), ...(opacity !== undefined && { opacity }), ...(transparent !== undefined && { transparent }), ...(wireframe !== undefined && { wireframe }), ...(emissive && { emissive }), ...(emissiveIntensity !== undefined && { emissiveIntensity }), ...(side && { side }), ...(flatShading !== undefined && { flatShading }), ...(properties && { properties }), }; await apiClient.updateMaterial(sceneId, materialId, updateData); return { content: [ { type: 'text', text: `Material ${materialId} updated successfully` } ] }; } catch (error) { return { content: [ { type: 'text', text: `Error updating material: ${error.message}` } ], isError: true }; } } );
- src/utils/api-client.js:134-136 (helper)Helper method in API client that sends PUT request to update material properties in the Spline API.async updateMaterial(sceneId, materialId, properties) { return this.request('PUT', `/scenes/${sceneId}/materials/${materialId}`, properties); }
- src/index.js:89-89 (registration)Invocation of registerMaterialTools which includes registration of 'updateMaterial' tool.registerMaterialTools(server);